-
Notifications
You must be signed in to change notification settings - Fork 75
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
[vscode] 7/n listeners and .env #1390
Conversation
0a3c8e6
to
8df06ee
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.
for anyone unaware,
[ENV_FILE_PATH]
is syntax equivalent to resolving the value of ENV_FILE_PATH
as the key for the js object.
vscode-extension/package.json
Outdated
"vscode-aiconfig.env_file_path": { | ||
"type": "string", | ||
"default": "", | ||
"description": "env_file_path" |
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.
Description should be clearer on what this is for
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 to "File path to your .env file containing your API keys"
Summary: This diff modifies the AIConfig start and edit commands to take in an dot env path. Due to core utils logic of handling args, the help messages automatically get updated too. Also Removes the loadenv() on server init. This is okay because loadenv is invoked at the run step. [see 4/n](#1384) Test Plan: ``` ankush@ap-mbp aiconfig % aiconfig start -h /opt/homebrew/lib/python3.11/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field "model_parsers" has conflict with protected namespace "model_". You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`. warnings.warn( usage: aiconfig start [-h] [--server-port SERVER_PORT] [--log-level LOG_LEVEL] [--server-mode {debug_servers,debug_backend,prod}] [--parsers-module-path PARSERS_MODULE_PATH] [--env-file-path ENV_FILE_PATH] options: -h, --help show this help message and exit --server-port SERVER_PORT --log-level LOG_LEVEL --server-mode {debug_servers,debug_backend,prod} --parsers-module-path PARSERS_MODULE_PATH **--env-file-path ENV_FILE_PATH** ```
Summary: Stack contains changes that updates overall environment setup flow for vscode extension. This diff adds support to call "SET_ENV_FILE_PATH" implemented in the previous diff. No functional changes. Test Plan:
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(async (event) => { | ||
if (event.affectsConfiguration("vscode-aiconfig")) { | ||
// Get new env | ||
const envPath = vscode.workspace.getConfiguration("vscode-aiconfig").get(ENV_FILE_PATH) as string; |
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.
Same here, unless deleting it makes its value empty string instead of undefined
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.
Just checked really quickly and this get method returns an empty string when it is never set. I think this might be configured in the package.json but I'm unaware of how this works at the moment.
vscode-extension/src/extension.ts
Outdated
@@ -208,6 +210,25 @@ export async function activate(context: vscode.ExtensionContext) { | |||
} | |||
) | |||
); | |||
|
|||
// Handle changes to the .env path | |||
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(async (event) => { |
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.
no need for async
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.
Just a few small things
Summary: When the .env file path is set, vscode will invoke api/set_env on each AIConfig server. Defines a listener to a newly introduced setting for the env_file_path. This ensures that users do not need to restart vscode to pickup env changes. Test Plan: 1. set env file path 2. changes picked up 3. changes picked up on restart 4. Changes picked up when manually removing vscode setting and re-setting env file path and api key https://github.com/lastmile-ai/aiconfig/assets/141073967/07ac1d43-28ef-439f-98e7-94a4e73e11c9
|
[vscode] 8/n Remove LCA env checks Summary: Now that a user can specify a .env file path with no restrictions on its location, the LCA checks need to be removed. LCA = Lowest Common Ancestor Test Plan: --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/1398). * __->__ #1398 * #1390 * #1387 * #1389
[vscode] 7/n listeners and .env
Summary:
When the .env file path is set, vscode will invoke api/set_env on each AIConfig server.
Defines a listener to a newly introduced setting for the env_file_path.
This ensures that users do not need to restart vscode to pickup env changes.
Test Plan:
testplan.mp4
Stack created with Sapling. Best reviewed with ReviewStack.