Skip to content

Add default file to example persistent_params_from_file - #606

Open
stefanthorstenson wants to merge 3 commits into
masterfrom
stefan/example-parameter-add-default-file
Open

Add default file to example persistent_params_from_file#606
stefanthorstenson wants to merge 3 commits into
masterfrom
stefan/example-parameter-add-default-file

Conversation

@stefanthorstenson

Copy link
Copy Markdown
Contributor

Add default file to example persistent_params_from_file.py.

Tested:

$ python persistent_params_from_file.py
Persistent params: stored activeMarker.back!

@ArisMorgens ArisMorgens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! I left some comments that could reduce user confusion.

@@ -0,0 +1,7 @@
params:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add a comment about what this file is about?
e.g. # Used in persistent_params_from_file.py

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Added comment and changed name of the file to indicate relationship to python script.

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--file', type=str, help='The yaml file containing the arguments. ')
parser.add_argument('-f', '--file', type=str, default='params.yaml',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A common way to run an example in cflib is to use uv from the root of the repo, since that's where the pyproject.toml is. (uv run examples/parameters/persistent_params_from_file.py). This won't work now because the file path is relative to the root. We could use something like os.path.join(os.path.dirname(os.path.abspath(__file__)), 'params.yaml') to fix that. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! Will fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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