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

modern path handling and pydantic implementation #82

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from

Conversation

benatouba
Copy link
Contributor

Fixes #80
Fixes #81

The aim of this pull request is mainly to simply further development and enhance user experience, at setup and running of the model.

Please look at the commits and commit messages and give your thoughts.

Description in commit messages.

Work needed:

  • Further specification of Pydantic models.
  • General review

All tests are passing on Python3.12

Transform all path variables to the more modern `pathlib.Path` object.
This helps with cross-platform compatibility and makes the code more
readable.

Some type annotations were also passed.
Meant to be applied in conjunction with a move to Pydantic for configuration validation.

NOTE: If cherry-picked, needs to be revised carefully as the commit is
meant to be applied with a move to Pydantic.

Fixes cryotools#81
Fail early, fail gracefully.

Implements config validation via pydantic for CosipyConfig
(main_config), SlurmConfig (slurm_config) and Constants
(constants_config, still needs more detailed model description).

NOTE: Other configs are still missing.

This provides config validation similar to dataclasses but more
elaborate. The validation at runtime allows us to check early on
if any config is missing or invalid and stops the model with informative
error messages.

Furthermore pydantic provides us type information, which makes it easier
to extend the code as the project gets larger.

While implementing this, I already found that the previous `Constants`
class was missing some entries that are in the `constants.toml` file.

Flattening the config structure (as done before) is now done before
model validation by use of pydantics `@model_validator` decorator.

NOTE: This is supposed to be a first draft and further details should be
implemented.

IMPORTANT: Look for NOTE, FIXME, and HACK comments in the code.
@gampnico
Copy link
Collaborator

How would you feel about splitting this into two separate pull requests, one with your pydantic classes for #81, and one with your better pathing type safety for #80?

Would it also be possible for you to launch pull requests from individual feature branches from your repository, rather than from your development branch? This means others can edit your commits without having to overwrite your own development branch (and potentially breaking things there).

@benatouba benatouba mentioned this pull request Nov 29, 2024
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