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

Adds option to specify config location using env variable #110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aturner-epcc
Copy link

Adds the option to set CATS_CONFIG_FILE environment variable to specify config file location. Config file location precedence becomes:

  1. Command line option
  2. Location specified in CATS_CONFIG_FILE
  3. ./config.yaml

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 88.33%. Comparing base (31cfede) to head (eeb961c).
Report is 1 commits behind head on main.

Files Patch % Lines
cats/configure.py 33.33% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #110      +/-   ##
==========================================
- Coverage   89.23%   88.33%   -0.91%     
==========================================
  Files          14       14              
  Lines         548      557       +9     
==========================================
+ Hits          489      492       +3     
- Misses         59       65       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@andreww andreww left a comment

Choose a reason for hiding this comment

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

Looks like a useful addition. It would be good to have a test case but I think that's easy given what we have.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I expect there will be a merge conflict for this file if #111 gets merged first. Should be easy to resolve.

Comment on lines +80 to +88
# if no path provided, try to use config environment variable
cfile = os.getenv("CATS_CONFIG_FILE")
if cfile is not None:
try:
with open(cfile, "r") as f:
return yaml.safe_load(f)
logging.info("Using config.yml found in CATS_CONFIG_FILE\n")
except FileNotFoundError:
logging.warning("CATS_CONFIG_FILE config file not found")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would benefit from a test being added to test_configure.py (which will stop codecov throwing a fit). I'll see if I can add something to this PR for that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've created a PR against your main branch - I think that will add a test to this PR if you merge it.

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