Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Do not call generate_metadata() on export when config is not valid #793

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

tnatt
Copy link
Collaborator

@tnatt tnatt commented Sep 20, 2024

Closes #602

  • Added a new function to get the export path of an object without having to fetch it from the metadata. This is used when invoking the export function and the config is not valid (i.e. no metadata should be exported)
  • Added deprecation warning for the generate_metadata function saying in the future no metadata will be returned if the config is invalid
    • once the deprecation period has ended we can remove checks of the validity of the config inside the generate_export_metadata, and remove masterdata and access as optional fields in the pydantic model used to generate metadata.

@tnatt tnatt force-pushed the config_invalid_behaviour branch from b79e525 to 0fbf4af Compare September 20, 2024 15:01
@perolavsvendsen
Copy link
Member

Still export data (without metadata)?

@tnatt
Copy link
Collaborator Author

tnatt commented Sep 20, 2024

Still export data (without metadata)?

Yes, no change in today's functionality. Simply a refactoring to find the export path to the object without having to create metadata first.

This way we can avoid several checks of the validity of the config, and align the pydantic model used to generate metadata more to the one used for the schema. + users not interested in metadata won't get annoyed by validation errors 👍

So to be clear today we do a pure export of the object if the config is not valid, i.e. no metadata is exported. This is not changed here 🙂

@tnatt tnatt force-pushed the config_invalid_behaviour branch 6 times, most recently from e83d1fb to 68bd6b9 Compare September 23, 2024 10:01
@tnatt tnatt force-pushed the config_invalid_behaviour branch from 68bd6b9 to 37a24cc Compare September 24, 2024 12:43
@tnatt tnatt changed the title ENH: Stop generating metadata when config is not valid ENH: Stop generating metadata on export when config is not valid Sep 24, 2024
Copy link
Collaborator

@mferrera mferrera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any extra mentions needed for the dataio 3.0 migration guide?

Nice job, this is a step in the right direction.

(Had a group review)

if not newsettings:
return

warnings.warn(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this warning was just moved since we need to run this _update_check_settings several places. The entire function can be removed once we move towards fmu.dataio 3.0

outfile = Path(metadata["file"]["absolute_path"])
# create output folders if they don't exist
outfile.parent.mkdir(parents=True, exist_ok=True)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved inside export_file

@@ -308,16 +397,19 @@ def test_rep_include(globalconfig1, regsurf):
mymeta = exp.generate_metadata(regsurf)
assert mymeta["access"]["ssdl"]["rep_include"] is True

# test that rep_include is taken from config if not provided
# test that rep_include is defaulted to false if not provided
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this test since rep_include no longer is included in the config by default

@tnatt tnatt force-pushed the config_invalid_behaviour branch from 37a24cc to 063c027 Compare September 24, 2024 13:06
@tnatt
Copy link
Collaborator Author

tnatt commented Sep 24, 2024

Any extra mentions needed for the dataio 3.0 migration guide?

Nice job, this is a step in the right direction.

(Had a group review)

Was just in the process of entering it into the migration guide 🙂 should be there now!

@tnatt tnatt force-pushed the config_invalid_behaviour branch from 063c027 to 40db19a Compare September 24, 2024 13:07
@tnatt tnatt changed the title ENH: Stop generating metadata on export when config is not valid ENH: Do not call generate_metadata() on export when config is not valid Sep 24, 2024
@tnatt tnatt force-pushed the config_invalid_behaviour branch from 40db19a to d12c2f8 Compare September 24, 2024 13:17
@tnatt tnatt merged commit f026cad into equinor:main Sep 24, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve behavior when non-valid config
3 participants