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

Remove BASE_DIR parsing for settings #105

Closed
wants to merge 1 commit into from
Closed

Remove BASE_DIR parsing for settings #105

wants to merge 1 commit into from

Conversation

b-rowan
Copy link
Contributor

@b-rowan b-rowan commented Aug 29, 2024

settings.yaml being parsed from a base directory has issues when being installed from pip. The user must now pass a settings_file path to goosebit when running.

With these changes, gooseBit should be run with python -m goosebit [settings_file]. There is also now help information with python -m goosebit --help.

Fixes: #103

@b-rowan
Copy link
Contributor Author

b-rowan commented Aug 29, 2024

Also note, settings_file has to be optional, because tests will break otherwise. All settings should have a valid default.

`settings.yaml` being parsed from a base directory has issues when being installed from pip.  The user must now pass a `settings_file` path to goosebit when running.

With these changes, gooseBit should be run with `python -m goosebit [settings_file]`.  There is also now help information with `python -m goosebit --help`.

Fixes: #103
Comment on lines +66 to +74
# skip arg parsing if running pytest
if "pytest" not in sys.modules:
cli_args = parser.parse_args()
return (
init_settings,
YamlConfigSettingsSource(settings_cls, cli_args.settings_file),
env_settings,
file_secret_settings,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a fan of this personally, but I cant think of a better option with the current project structure...

Copy link
Collaborator

@easybe easybe Aug 29, 2024

Choose a reason for hiding this comment

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

This looks awful. There must be a better way.

Copy link
Collaborator

@easybe easybe left a comment

Choose a reason for hiding this comment

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

I don't think this is going into the right direction. What if you want to run the service with e.g. gunicorn together with a settings file?

I would rather see the app search for a system-wide file (e.g. in /etc) and maybe the current directory. This can be made portable with e.g. the platformdirs package.

@@ -0,0 +1,5 @@
import argparse
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not where I would expect argument parsing. IMHO this should be in __main__.py.

@b-rowan
Copy link
Contributor Author

b-rowan commented Aug 29, 2024

I don't think this is going into the right direction. What if you want to run the service with e.g. gunicorn together with a settings file?

I would rather see the app search for a system-wide file (e.g. in /etc) and maybe the current directory. This can be made portable with e.g. the platformdirs package.

Fair enough. Closing because I dont think this makes much sense then

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.

Fix storage location of settings.yaml
3 participants