Skip to content

Adding dotenv to cli#41

Open
assaftibm wants to merge 1 commit into
skydiscover-ai:mainfrom
assaftibm:dotenv_for_cli
Open

Adding dotenv to cli#41
assaftibm wants to merge 1 commit into
skydiscover-ai:mainfrom
assaftibm:dotenv_for_cli

Conversation

@assaftibm

@assaftibm assaftibm commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Loading environment variables from a .env file when running from the cli.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the command-line interface (CLI) by integrating python-dotenv, which allows for the automatic loading of environment variables from .env files. This change simplifies configuration management for the CLI, making it easier to set up and run the application with environment-specific settings without modifying code.

Highlights

  • Dependency Update: The python-dotenv package has been added as a core dependency for the project, ensuring its availability across all environments.
  • Dependency Refactoring: The python-dotenv dependency was removed from the frontier-cs optional dependency group, as it is now a core dependency.
  • Environment Variable Loading: The skydiscover/cli.py file now imports and calls load_dotenv() to automatically load environment variables from a .env file upon CLI execution.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds python-dotenv to load environment variables from a .env file for the CLI. The dependency is correctly moved to the core dependencies. However, the call to load_dotenv() is at the module level in skydiscover/cli.py, which can cause side effects, especially for testing. I've recommended moving this call into the main() function to scope its execution to when the CLI is run as a script, which will improve testability and prevent unexpected behavior when the module is imported elsewhere.

Comment thread skydiscover/cli.py

logger = logging.getLogger(__name__)

load_dotenv()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Calling load_dotenv() at the module level can cause unintended side effects, especially during testing. For example, tests/test_cli_checkpoint_discovery.py imports a function from this module, which would trigger load_dotenv() and could make tests dependent on a .env file or modify the environment unexpectedly.

It's better to move this call inside the main() function to ensure it only runs when the CLI is executed as a script. This will isolate the side effect of loading environment variables to the application's entry point. You should remove this line and add load_dotenv() to your main function, like so:

def main() -> int:
    """Synchronous entry point for the skydiscover console script."""
    load_dotenv()
    return asyncio.run(main_async())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can make this change if requested. Note that there are main() and main_async(). I'm not sure which of them to update (or maybe both).

@assaftibm

Copy link
Copy Markdown
Contributor Author

Hi @lynnliu030 , any input from you on this?

@lynnliu030 lynnliu030 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hi @assaftibm, sorry for the delay! I think put it in main() only is fine, which is the CLI entry point. No need to add it to both. Thanks for the contribution!

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