-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add Default Machine Setting #383
Add Default Machine Setting #383
Conversation
Add a feature that read and write `.local_settings` (repository level) and `global_settings` (user level) files to save the default machine. Add tool/set_settings.sh script to setup the default machine. In src/configure.py: - Change the default of `--machine` to None. - Add function `get_machine()` to read the default machine setting. - Raise FileNotFoundError if the .config file is not found. Add `src/.local_settings` to .gitignore.
They will fall back to `eureka_intel` when not specified. If not removed, `--machine=eureka_intel` will override the user setting.
0c417fe
to
b0573ce
Compare
Fix `get_default()` in `SystemSetting`. Replace except with non-explicit exception. Remove `_`, an alias from gettext module, which is not used.
Give ability to add more parameters and add delete option. All done by Copilot O1-preview!
Add options verbose, list, and clear-all. Some changes with a better cli flow Use PADDED_KEYS for better alignment. Accept short options to be combined.
30d0910
to
7fd4994
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@technic960183 Thanks for the contribution. I have left some comments. There are some typos and a bug that need to be fixed. The rest of the comments are optimization and improving maintainability. Let me know if you have better ideas, or we can discuss it at the lab.
Co-authored-by: ChunYen-Chen <chunyenchen2019@gmail.com>
- Use global variable to store the return value of a function. - Redirect error messages to stderr.
- Improve usage messages - Make `-v` and `-l` works the same - Remove `realpath` for macOS compatibility
For supporting the use of type annotations
@technic960183 Please resolve the conflicts. |
Co-authored-by: Chun-Yen Chen <70311975+ChunYen-Chen@users.noreply.github.com>
`_get_option_tuples` was overriden before to disable abbreviation for Python 3.4 and below. The parameter `allow_abbrev` was added in Python 3.5. Now, since in this pull request gamer-project#383 we ask for Python 3.5 or above, we can remove the override and set `allow_abbrev` to `False`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed comments.
I have fixed some problems and leave 2 questions (which I have tagged you).
I do not agree with some of the suggestion and have commented the reasons. Please tell me what you think. Thanks.
a7366e3
to
435d58e
Compare
Links: - Installation:-Option-List#--machine - Installation#default_setting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks for the review and suggestions.
680579c
to
9d30e5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@technic960183 This PR looks great and works well. Thanks for the contribution! I've added some comments before merging. Besides, here is a general question:
- Currently if
src/.local_settings
exists, even if it's empty, we completely ignore~/.config/gamer/global_settings
. I want to confirm if this behavior is intentional. For example, if both setting files exist, butmachine
is specified only inglobal_settings
but not.local_settings
, should we- Adopt the default value
eureka_intel
, as specified inconfigure.py
, or - Adopt the value set in
global_settings
?
- Adopt the default value
doc/wiki/Installation-related/Installation:-Machine-Configuration-File.md
Outdated
Show resolved
Hide resolved
doc/wiki/Installation-related/Installation:-Machine-Configuration-File.md
Outdated
Show resolved
Hide resolved
doc/wiki/Installation-related/Installation:-Machine-Configuration-File.md
Outdated
Show resolved
Hide resolved
Docs related suggestion Co-authored-by: Hsi-Yu Schive <hyschive@gmail.com>
Co-authored-by: Hsi-Yu Schive <hyschive@gmail.com>
The empty local setting will not overwrite the global setting now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have applied the suggestion and fixed the bug.
And the PR description is completely updated with a new testing tasks list.
@hyschive
It is a bug that if the .local_settings
is empty, global_settings
is ignored. I have fixed it and thanks for the catch.
I have also fixed the bug if there are more than one avaiable setting exist. Now each setting will override independently.
@ChunYen-Chen
I have removed load_setting()
and put the functionality into the class SystemSetting
. Please help me to review it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@technic960183 Thanks for the updates and the bug fixes. Please fix the minor style comments. Sorry for not testing the PR fully after the update of the set_setting.sh
.
Co-authored-by: Chun-Yen Chen <70311975+ChunYen-Chen@users.noreply.github.com>
e3cca1d
to
948ed71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@technic960183 Works great! Thanks for the contribution!
Summary
This PR introduces a mechanism to specify default machine settings at both the repository and user levels, enhancing flexibility and usability in configuring the
--machine
argument forconfigure.py
.Rationale
This design mirrors common configuration practices used by tools such as
git
,vim
, andyt
, offering flexibility with multiple levels of configuration. The repository-level setting provides a tailored environment for specific projects (as @ChunYen-Chen ask for), while the user-level setting allows global defaults (as @hyschive ask for).Features Added
Two Levels of Default Settings:
Repository-Level (
.local_settings
): Located insrc/.local_settings
to specify default settings for a specific repository.User-Level (
global_settings
): Stored in$HOME/.config/gamer/global_settings
, serving as a global fallback when repository-level settings are absent.In this PR, there is only one setting
machine
in the default setting file. But this feature is capable of adding more settings easily.Note: The name of the setting files are not
.gamerrc
because this is not a "rc" (runtime configuration) for GAMER.Backward compatibility
The default machine is determined in the following order:
configure.py
.eureka_intel
.Files Changed
Changes in
src/configure.py
Major
SystemSetting
.--machine
is not given, it will look forsys_setting.get_default()
which store the setting from the default setting files.FileNotFoundError
if the.config
files are not found.Minor
_get_option_tuples
overridden. And addallow_abbrev=False
toArgumentParser
.try-except
with a specify condition checking.Add Setting Script
tool/config/set_settings.sh
A new script
tool/set_settings.sh
is provided to help users set the default setting (default machine here) during the initial setup.Update related Wiki pages
Installation
: Add guide to set the default machine and remove--machine
related words.Installation: Machine Configuration File
: Improve the reading flow.Installation: Option List
: Add description about the default machine.Quick Start
: Add guide to set the default machine and improve the reading flow.Quick Start: 1D Shock Tube
: Remove--machine
related words.Removal of Hardcoded Defaults in
generate_make.sh
Removed hardcoded
--machine=eureka_intel
in these scripts, ensuring that the new hierarchical default mechanism is utilized.Updated
.gitignore
Added
src/.local_settings
to.gitignore
to avoid tracking repository-level configuration files.Tests
configure.py --machine=
override the setting files and works if the settings files are not set.eureka_intel
works.Other Major Change
Check the version of Python. Require Python 3.5 or later to run
configure.py
.Python 3.4 has ended its life nearly 6 years ago (since 2019-03-18). It will be fine for us to not support Python 3.4 and lower.
Ref: https://devguide.python.org/versions/