Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

CLI: read config file from env location (Issue #189) #190

Merged
merged 4 commits into from
Dec 10, 2023

Conversation

MichaelAnckaert
Copy link
Contributor

This PR fixes the bug described in issue #189.

Problem

The issue occurs then the user runs a Canopy CLI command (such as new, upsert) and does not specify the -c parameter with a config file lcoation.
The current behaviour is to default to an empty (default) configuration while the user might expect Canopy to read the config file location specified in the environment variable CANOPY_CONFIG_FILE.

Solution

This change updates the way the config file is loaded by the Canopy CLI. When the config file location is not specified through the -c parameter, we use the file location specified in the environment variable CANOPY_COPY_FILE.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

Only manual testing was done for this change.

This commit updates the way the config file is loaded by the Canopy CLI.
When the config file location is not specified through the `-c`
parameter, we use the file location specified in the environment
variable CANOPY_COPY_FILE.
@@ -102,7 +102,9 @@ def _initialize_tokenizer():

def _read_config_file(config_file: Optional[str]) -> Dict[str, Any]:
if config_file is None:
return {}
config_file = os.getenv("CANOPY_CONFIG_FILE", None)
Copy link
Contributor

@igiloh-pinecone igiloh-pinecone Dec 3, 2023

Choose a reason for hiding this comment

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

I believe click has a built-in solution.
If you'll look at the click declaration of the --index-name argument of canopy new, you'd notice an envvar= option that that automatically sets that argument to also be read from an en var.

Copy link
Contributor

@igiloh-pinecone igiloh-pinecone left a comment

Choose a reason for hiding this comment

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

LGTM!

(Have manually fixed PR comments that wasn't fixed for a week)

@igiloh-pinecone igiloh-pinecone added this pull request to the merge queue Dec 10, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 10, 2023
@igiloh-pinecone igiloh-pinecone added this pull request to the merge queue Dec 10, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 10, 2023
@igiloh-pinecone igiloh-pinecone added this pull request to the merge queue Dec 10, 2023
Merged via the queue into pinecone-io:main with commit b129a05 Dec 10, 2023
11 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants