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

reading default values from yml files #23

Merged
merged 11 commits into from
Mar 27, 2024
Merged

Conversation

neuronflow
Copy link
Contributor

Signed-off-by: neuronflow [email protected]

Signed-off-by: neuronflow <[email protected]>
@neuronflow neuronflow marked this pull request as draft December 15, 2023 14:38
@@ -188,6 +188,7 @@ def update_parameters(self, config_file: Union[str, dict], **kwargs):
)

# this is taken directly from the sample_config.yaml
# TODO this is ugly we should probbaly read these defaults from a file?
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are pros and cons for both the mechanisms. If we are reading from a file, we need to ensure that the file is packaged in pypi in a manner that works across various platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this is solved :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah it was not commited yet, see commits below

@neuronflow neuronflow changed the title add todo for later reading default values from yml files Dec 15, 2023
def _generate_default_parameters(self) -> dict:
defaults_file = os.path.normpath(
os.path.abspath(
__file__ + "configurations/default_config.yaml",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
__file__ + "configurations/default_config.yaml",
__file__ + "configurations/sample_config.yaml",

No need for another config file at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then we need to move the other files to this location :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure!

@@ -0,0 +1,95 @@
# TODO adjust default parameters!
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file can be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it is a placeholder. the files we want to include into the pkg should be subfolders of the ereg folder :)

@sarthakpati
Copy link
Collaborator

This PR also needs changes in the MANIFEST and pyproject.tml files in accordance with the documentation here (or something similar): https://setuptools.pypa.io/en/stable/userguide/datafiles.html

@neuronflow
Copy link
Contributor Author

This PR also needs changes in the MANIFEST and pyproject.tml files in accordance with the documentation here (or something similar): https://setuptools.pypa.io/en/stable/userguide/datafiles.html

should work without a manifest, at least in brainles preprocessing we also include files without a manifest [I believe the reason it works is that we use poetry]

@sarthakpati
Copy link
Collaborator

This PR also needs changes in the MANIFEST and pyproject.tml files in accordance with the documentation here (or something similar): https://setuptools.pypa.io/en/stable/userguide/datafiles.html

should work without a manifest, at least in brainles preprocessing we also include files without a manifest [I believe the reason it works is that we use poetry]

Oh okay. Should be fine as long as we can verify this without having to push a new version to pip.

@neuronflow
Copy link
Contributor Author

This PR also needs changes in the MANIFEST and pyproject.tml files in accordance with the documentation here (or something similar): https://setuptools.pypa.io/en/stable/userguide/datafiles.html

should work without a manifest, at least in brainles preprocessing we also include files without a manifest [I believe the reason it works is that we use poetry]

Oh okay. Should be fine as long as we can verify this without having to push a new version to pip.

hmm if it works with pip install -e . and the defaults are loaded it should be fine?

@sarthakpati
Copy link
Collaborator

This PR also needs changes in the MANIFEST and pyproject.tml files in accordance with the documentation here (or something similar): https://setuptools.pypa.io/en/stable/userguide/datafiles.html

should work without a manifest, at least in brainles preprocessing we also include files without a manifest [I believe the reason it works is that we use poetry]

Oh okay. Should be fine as long as we can verify this without having to push a new version to pip.

hmm if it works with pip install -e . and the defaults are loaded it should be fine?

Cool! Move the sample_config and default_rigid files under configurations, remove the new one and we should be good!

@neuronflow
Copy link
Contributor Author

currently we pkg everything that is under the ereg folder, I have to check whether .yml files are excluded, but I don't think so

Signed-off-by: neuronflow <[email protected]>
@neuronflow
Copy link
Contributor Author

@sarthakpati so @IsraMekki0 and I went through the code today, we added this property:

@property

This enables users to change the configuration of a registrator instance with
registrator.configration = "new_config.yml"
(before this might have lead to unexpected behavior)

Further, we added the possibility to read in defaults from the .yml

now what seems missing is that the update_parameters method only updates the parameters which are contained in the supplied dict. I don't think this method should supply defaults, this way we would have a single source of truth (the config file) file?

# TODO rewrite this function to only update specific entries which are given in the dict

@sarthakpati
Copy link
Collaborator

Sounds great! Thanks, @IsraMekki and @neuronflow

"bias_correct", self.parameters.get("bias", False)
)
self.parameters["interpolator"] = (
self.parameters.get("interpolator", "linear")
Copy link
Contributor Author

@neuronflow neuronflow Dec 15, 2023

Choose a reason for hiding this comment

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

I don't fully understand why this is done @sarthakpati . The

            .replace("_", "")
            .replace("-", "")
            .lower()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sarthakpati did you see this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Uh, I think this is to just remove these specific special characters to make the comparisons easier in the next lines.

@neuronflow neuronflow added enhancement New feature or request help wanted Extra attention is needed labels Dec 15, 2023
@neuronflow neuronflow marked this pull request as ready for review March 27, 2024 20:44
@sarthakpati sarthakpati enabled auto-merge March 27, 2024 20:46
@sarthakpati sarthakpati merged commit aedc922 into main Mar 27, 2024
6 checks passed
@sarthakpati sarthakpati deleted the add_config_file_property branch March 27, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] we want to have a single source of truth for default parameters
3 participants