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

Initialize ExportData with tmp config obj from AggregatedData. #626

Merged

Conversation

perolavsvendsen
Copy link
Member

Solve #625 and silence warning about erroneous config. It is spamming the logs on our service, and the text is misleading (see issue).

@perolavsvendsen
Copy link
Member Author

Ref options listed in the issue, I am not convinced that this is the best way of solving this. It feels a bit like duct tape. Open for opinions and suggestions.

@tnatt
Copy link
Collaborator

tnatt commented Apr 22, 2024

yes, it feels a bit hacky which is why I took it away recently 🙂 but I see the problem with logs being spammed. This AggregatedData needs a bit of attention later, but for now I guess taking this fake config back could be an option..

Or probably better, rewrite:

self._config_is_valid = global_configuration.is_valid(self.config)

to:
self._config_is_valid = global_configuration.is_valid(self.config) if self.config else False

That will silence the pydantic warnings, and there is no need of validating the config if it is not given anyway 👍

@tnatt
Copy link
Collaborator

tnatt commented Apr 22, 2024

And then we move the warning regarding missing config and that the metadata will be empty to when the user try to create metadata instead. So that when using this AggregatedData, the users are not exposed to it.

@perolavsvendsen
Copy link
Member Author

perolavsvendsen commented Apr 22, 2024

self._config_is_valid = global_configuration.is_valid(self.config)

to: self._config_is_valid = global_configuration.is_valid(self.config) if self.config else False

That will silence the pydantic warnings, and there is no need of validating the config if it is not given anyway 👍

Yes, that looks potentially more elegant. But are there unwanted side-effects? Wouldn't this fail to warn if ExportData is attempted initialized without config in other contexts? (Do we want that?)

Edit: This will then fail to trigger:

with pytest.warns(UserWarning, match=pydantic_warning()):

@tnatt
Copy link
Collaborator

tnatt commented Apr 22, 2024

self._config_is_valid = global_configuration.is_valid(self.config)

to: self._config_is_valid = global_configuration.is_valid(self.config) if self.config else False
That will silence the pydantic warnings, and there is no need of validating the config if it is not given anyway 👍

Yes, that looks potentially more elegant. But are there unwanted side-effects? Wouldn't this fail to warn if ExportData is attempted initialized without config in other contexts? (Do we want that?)

Hm, maybe... And eventually we are moving towards requiring a valid config as input, so probably making the fake config here is the best solution for now 👍 and then we'll address it later when we give some attention to this class 🙂

@perolavsvendsen
Copy link
Member Author

Ah, did not see the last comment until now. Tried the (previously) suggested change. Can revert back if we liked the first one better. #dontmerge

@perolavsvendsen
Copy link
Member Author

Which one do we want? First or second...?

@tnatt
Copy link
Collaborator

tnatt commented Apr 22, 2024

Which one do we want? First or second...?

I say first!

@perolavsvendsen
Copy link
Member Author

Which one do we want? First or second...?

I say first!

Backtracked, now using fake config again ✅

@perolavsvendsen
Copy link
Member Author

@tnatt happy? OK to merge...?

@tnatt
Copy link
Collaborator

tnatt commented Apr 22, 2024

@tnatt happy? OK to merge...?

Yes 👍

@perolavsvendsen perolavsvendsen merged commit 74a5d6f into equinor:main Apr 23, 2024
13 checks passed
@perolavsvendsen perolavsvendsen deleted the 625-misleading-agg-warning branch April 23, 2024 06:37
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.

2 participants