Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
The versions coincide with releases on pip. Only major versions will be released as tags on Github.

## [0.0.x](https://github.scom/singularityhub/singularity-hpc/tree/master) (0.0.x)
- Central config should be read first (and updated with user config) (0.0.4)
- Add support for oras pull for singularity (0.0.39)
- Bug with setting a nested value (0.0.38)
- Adding quotes around tcl descriptions (0.0.37)
Expand Down
5 changes: 4 additions & 1 deletion docs/getting_started/user-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ take preference over this one as follows:
$ shpc config userinit


The defaults in either file are likely suitable for most. For any configuration value
When you create a user settings file (or provide a custom settings file one off to
the client) the shpc default settings will be read first, and then updated by your file.
We do this so that if the default file updates and your user settings is missing a variable,
we still use the default. The defaults in either file are likely suitable for most. For any configuration value
that you might set, the following variables are available to you:

- ``$install_dir``: the shpc folder
Expand Down
12 changes: 9 additions & 3 deletions shpc/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self):
# Set an updated time, in case it's written back to file
self._settings = {"updated_at": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")}
self.settings_file = None
self.user_settings = None

def __str__(self):
return "[shpc-settings]"
Expand Down Expand Up @@ -81,7 +82,7 @@ def edit(self):

def get_settings_file(self, settings_file=None):
"""
Get the preferred used settings file.
Get the preferred user settings file, set user settings if exists.
"""
# Only consider user settings if the file exists!
user_settings = None
Expand All @@ -106,10 +107,15 @@ def load(self, settings_file=None):
yaml = YAML()
yaml.preserve_quotes = True

# Store the original settings for update as we go
with open(self.settings_file, "r") as fd:
# Always load default settings first
with open(defaults.default_settings_file, "r") as fd:
self._settings = yaml.load(fd.read())

# Update with user or custom settings if not equal to default
if self.settings_file != defaults.default_settings_file:
with open(self.settings_file, "r") as fd:
self._settings.update(yaml.load(fd.read()))

def get(self, key, default=None):
"""
Get a settings value, doing appropriate substitution and expansion.
Expand Down
2 changes: 1 addition & 1 deletion shpc/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__copyright__ = "Copyright 2021-2022, Vanessa Sochat"
__license__ = "MPL 2.0"

__version__ = "0.0.39"
__version__ = "0.0.4"
AUTHOR = "Vanessa Sochat"
NAME = "singularity-hpc"
PACKAGE_URL = "https://github.com/singularityhub/singularity-hpc"
Expand Down