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

1/n [vscode & server] Reload Environment when invoking the Run Step #1376

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

Ankush-lastmile
Copy link
Member

@Ankush-lastmile Ankush-lastmile commented Feb 27, 2024

1/n [vscode & server] Reload Environment when invoking the Run Step

This diff modifies the AIConfig backend server to reload the environment everytime the Run Step is invoked. This will allow api keys that are newly added to be picked up from the aiconfig server, without the need to restart the server.

I validated that load_dotenv does not add any noticeable latency.

import time
import dotenv

start = time.time()
dotenv.load_dotenv()
end = time.time()
print(end-start)
_____
0.0010402202606201172s

Surfaced from #1371, a restart of the server will no longer be required.

Ontop of this, we can pass a .env path directly the server initialization, instead of relying on a set of lowest-common-ancestor checks

Discussed offline with @saqadri

Testplan

testplan.mp4

@Ankush-lastmile Ankush-lastmile changed the title 1/n [vscode & server] Reload Environment at the Run Step 1/n [vscode & server] Reload Environment when invoking the Run Step Feb 27, 2024
Comment on lines +334 to +337

# Allow user to modify their environment keys without reloading the server.
# Execution time of `0.001s` is arbitrary, but should be small enough to not be noticeable.
dotenv.load_dotenv()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider just adding these to model parsers directly, but this moves us forwards and we can change that later if we want

This diff modifies the AIConfig backend server to reload the environment everytime the Run Step is invoked. This will allow api keys that are newly added to be picked up from the aiconfig server, without the need to restart the server.

I validated that `load_dotenv` does not add any noticeable latency.
```
import time
import dotenv

start = time.time()
dotenv.load_dotenv()
end = time.time()
print(end-start)
_____
0.0010402202606201172s
```

Surfaced from #1371, a restart of the server will no longer be required.

Ontop of this, we can pass a .env path directly the server initialization, instead of relying on a set of lowest-common-ancestor checks

Discussed offline with @saqadri

## Testplan

https://github.com/lastmile-ai/aiconfig/assets/141073967/c67cbb5c-785a-40b4-9aac-6cccfaff0004
@Ankush-lastmile
Copy link
Member Author

  • Updated testplan
  • discussed offline, more to come on top.

Quick summary:

  • load dot_env picks up the nearest .env in its file hierarchy.
  • server to be informed of a specific .env, and a new endpoint to aiconfig server to be implemented to update aiconfig server state containing.env path

@Ankush-lastmile Ankush-lastmile merged commit ccc04f3 into main Feb 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants