Skip to content

Development#16

Merged
gjbex merged 6 commits intomasterfrom
development
Mar 24, 2026
Merged

Development#16
gjbex merged 6 commits intomasterfrom
development

Conversation

@gjbex
Copy link
Copy Markdown
Owner

@gjbex gjbex commented Mar 24, 2026

Summary by Sourcery

Improve robustness of hands-on notebooks and extend examples around environment variables and Hydra logging configuration.

New Features:

  • Add on-demand installation of the sh module and conditional download of the Julia source file in the Julia hands-on notebook.
  • Introduce dotenv-based environment variable demo with supporting README, sample env file, and gitignore.
  • Configure Hydra-based custom logging via a new job_logging configuration file and document how to control log levels.
  • Add shell command and environment setup cells to the shell interaction notebook to illustrate direct shell usage and importing os.

Enhancements:

  • Update notebook metadata to target a modern Python ipykernel and recent Python version.
  • Clarify documentation for environment variable examples and Hydra usage, including how logging is configured through Hydra.

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 24, 2026

Reviewer's Guide

Makes the Julia and shell interaction notebooks more robust and self-contained, updates environment-variable and Hydra documentation, introduces a dotenv-based environment variable demo, and configures Hydra to use a custom logging setup.

Sequence diagram for dotenv_demo environment variable loading

sequenceDiagram
    actor User
    participant dotenv_demo
    participant os_env
    participant dotenv
    participant env_file
    participant Console

    User->>dotenv_demo: run dotenv_demo.py
    dotenv_demo->>os_env: check MY_SECRET in environ
    alt MY_SECRET present
        os_env-->>dotenv_demo: MY_SECRET found
        dotenv_demo->>Console: print "MY_SECRET is already set in the environment."
    else MY_SECRET absent
        os_env-->>dotenv_demo: MY_SECRET not found
        dotenv_demo->>Console: print "Loading environment variables from .env file..."
        dotenv_demo->>dotenv: load_dotenv()
        dotenv->>env_file: read .env
        env_file-->>dotenv: key value pairs
        dotenv-->>os_env: update environment
    end

    dotenv_demo->>os_env: getenv MY_SECRET
    os_env-->>dotenv_demo: secret_key
    alt secret_key present
        dotenv_demo->>Console: print "MY_SECRET_KEY: {secret_key}"
    else secret_key absent
        dotenv_demo->>Console: print "MY_SECRET not found in environment variables."
    end
Loading

File-Level Changes

Change Details Files
Make the Julia hands-on notebook self-contained and idempotent for sh installation and source download, and update kernel metadata.
  • Replace explicit pip-install code cell for sh with conditional import-and-install logic in the main import cell.
  • Guard the download of the Fortran source file so it only runs if the file is missing, and switch to the updated GitHub URL and repository path.
  • Clarify markdown instructions to explain conditional installation and download behavior.
  • Update notebook kernel metadata (display name, Python version, nbformat minor version).
hands-on/julia.ipynb
Enhance the shell interaction notebook with explicit shell and environment examples.
  • Add a code cell that runs a bare !ls -l shell command to complement the sh.ls example.
  • Insert an explicit import os cell before environment-variable examples to make the notebook self-contained.
hands-on/shell_interaction.ipynb
Document and demonstrate using dotenv for loading environment variables from a .env file.
  • Extend the environment-variables README to mention the dotenv package and its role.
  • Add a dotenv demo script that conditionally loads environment variables from a .env file and prints MY_SECRET.
  • Introduce a dotenv-focused README describing usage, inputs, and purpose.
  • Add supporting files for dotenv usage, including a template dot_env file and a .gitignore entry to ignore the real .env file.
source-code/enviroment-variables/README.md
source-code/enviroment-variables/dotenv/dotenv_demo.py
source-code/enviroment-variables/dotenv/README.md
source-code/enviroment-variables/dotenv/.gitignore
source-code/enviroment-variables/dotenv/dot_env
Configure Hydra-based example to use a custom logging configuration and document how to control logging via configuration.
  • Add a custom Hydra job_logging configuration that defines a simple console handler and INFO root level.
  • Update the main Hydra config defaults to include the custom job_logging override.
  • Extend the Hydra README with documentation and an example command showing how to change the log level via Hydra configuration.
source-code/hydra/README.md
source-code/hydra/conf/config.yaml
source-code/hydra/conf/hydra/job_logging/custom.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • In dotenv_demo.py the printed label MY_SECRET_KEY does not match the environment variable name MY_SECRET, which is likely to confuse users; align the message with the actual variable name (e.g. print MY_SECRET).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `dotenv_demo.py` the printed label `MY_SECRET_KEY` does not match the environment variable name `MY_SECRET`, which is likely to confuse users; align the message with the actual variable name (e.g. print `MY_SECRET`).

## Individual Comments

### Comment 1
<location path="source-code/enviroment-variables/dotenv/dotenv_demo.py" line_range="17-20" />
<code_context>
+        load_dotenv()
+
+    # Access an environment variable
+    secret_key = os.getenv('MY_SECRET')
+
+    if secret_key:
+        print(f'MY_SECRET_KEY: {secret_key}')
+    else:
+        print('MY_SECRET not found in environment variables.')
</code_context>
<issue_to_address>
**issue:** Inconsistent naming between the environment variable (`MY_SECRET`) and the printed label (`MY_SECRET_KEY`).

The code reads `MY_SECRET` from the environment but prints it as `MY_SECRET_KEY`, which can mislead users about which variable to configure. Please use a consistent name for both the environment lookup and the printed label (e.g., `MY_SECRET`).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread source-code/enviroment-variables/dotenv/dotenv_demo.py Outdated
@gjbex gjbex merged commit 3f9db2a into master Mar 24, 2026
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

Development

Successfully merging this pull request may close these issues.

1 participant