Updated other uses of environment variables to use get_environment_variables - #834
Draft
elenya-grant wants to merge 5 commits into
Draft
Updated other uses of environment variables to use get_environment_variables#834elenya-grant wants to merge 5 commits into
get_environment_variables#834elenya-grant wants to merge 5 commits into
Conversation
RHammond2
approved these changes
Aug 13, 2026
RHammond2
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the update, @elenya-grant! I just made one formatting suggestion, and this should be good from my perspective.
Comment on lines
+60
to
+67
| raise ValueError( | ||
| "`EIA_API_KEY` has not been set. Please set the `EIA_API_KEY` environment variable." | ||
| ) | ||
| if (eia_key := eia_api_key.get("EIA_API_KEY")) is not None: | ||
| return eia_key | ||
| raise ValueError( | ||
| "`EIA_API_KEY` has not been set. Please set the `EIA_API_KEY` environment variable." | ||
| ) |
Collaborator
There was a problem hiding this comment.
Suggested change
| raise ValueError( | |
| "`EIA_API_KEY` has not been set. Please set the `EIA_API_KEY` environment variable." | |
| ) | |
| if (eia_key := eia_api_key.get("EIA_API_KEY")) is not None: | |
| return eia_key | |
| raise ValueError( | |
| "`EIA_API_KEY` has not been set. Please set the `EIA_API_KEY` environment variable." | |
| ) | |
| msg = "`EIA_API_KEY` has not been set. Please set the `EIA_API_KEY` environment variable." | |
| raise ValueError(msg) | |
| if (eia_key := eia_api_key.get("EIA_API_KEY")) is not None: | |
| return eia_key | |
| msg = "`EIA_API_KEY` has not been set. Please set the `EIA_API_KEY` environment variable." | |
| raise ValueError(msg) |
Just maintaining the original use of msg for multiline raises for traceback legibility.
|
|
||
|
|
||
| def get_eia_api_key(api_key_file: Path | None) -> str: | ||
| def get_eia_api_key(api_key_file: Path | None, set_vars: bool = True) -> str: |
Collaborator
There was a problem hiding this comment.
I'm not remotely opposed to this, and think it's good for API consistency, but just commenting that it's likely not at all necessary since all desired data can be downloaded with a single API call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated other uses of environment variables to use
get_environment_variablesUpdated the other uses of environment variables (EIA API and setting custom resource of feedstock directories) to use the
get_environment_variablesfunction. The following functions were updated:get_eia_api_keyinh2integrate/preprocess/eia.pycheck_data_dirinh2integrate/core/file_utils.pySection 1: Type of Contribution
Section 2: Draft PR Checklist
TODO:
docs/getting_started/environment_variables.mdType of Reviewer Feedback Requested (on Draft PR)
Structural feedback:
Implementation feedback:
h2integrate/core/test/conftest.pybe updated to have similar logic in place forFEEDSTOCK_DIRas there is forRESOURCE_DIR? (@RHammond2)Other feedback:
Section 3: General PR Checklist
docs/files are up-to-date, or added when necessaryCHANGELOG.md"A complete thought. [PR XYZ]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
XYZshould be replaced with the actual number.Section 4: Related Issues
This is intended to resolve issue #802 and issue #765
Section 5: Impacted Areas of the Software
Section 5.1: New Files
N/A
Section 5.2: Modified Files
h2integrate/core/file_utils.pycheck_data_dir: updated to useget_environment_variablesh2integrate/preprocess/eia.pyget_eia_api_key: updated to useget_environment_variablesh2integrate/resource/utilities/nlr_developer_api_keys.pyget_nlr_developer_api_credential: updated doc stringdocs/getting_started/environment_variables.md: updated documentation mostly related toRESOURCE_DIRSection 6: Additional Supporting Information
Section 7: Test Results, if applicable