Skip to content

Example: update quickstart with latest features #20

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

Merged
merged 15 commits into from
Jun 25, 2025

Conversation

LeoRoccoBreedt
Copy link
Contributor

@LeoRoccoBreedt LeoRoccoBreedt commented Jun 5, 2025

Description

Include a summary of the changes and the related issue.

Related to: <ClickUp/JIRA task name>

Any expected test failures?


Add a [X] to relevant checklist items

❔ This change

  • adds a new feature
  • fixes breaking code
  • is cosmetic (refactoring/reformatting)

✔️ Pre-merge checklist

  • Refactored code (sourcery)
  • Tested code locally
  • Precommit installed and run before pushing changes
  • Added code to GitHub tests (notebooks, scripts)
  • Updated GitHub README
  • Updated the projects overview page on Notion

🧪 Test Configuration

  • OS: Windows
  • Python version: 3.12
  • Neptune version: 0.14
  • Affected libraries with version:

Summary by Sourcery

Add histogram logging to the Neptune quickstart examples, parameterize layer count, and introduce a utility to download external media files, along with associated guide and metadata updates.

New Features:

  • Log activation distributions as histogram series in notebook and script using get_activation_distribution and run.log_histograms
  • Introduce download_file helper to fetch and upload external image, video, and audio samples
  • Expose NUM_LAYERS constant to configure layer-based logging loops uniformly

Enhancements:

  • Update quickstart notebook’s table of contents and code sections to include file, string series, and histogram logging
  • Refactor code to remove redundant imports, streamline run creation output, and use constants consistently
  • Adjust notebook kernel spec and metadata to use Python 3.9

Documentation:

  • Add Markdown section explaining histogram logging and link to the Neptune histograms documentation

Copy link
Contributor

sourcery-ai bot commented Jun 5, 2025

Reviewer's Guide

This PR enriches the Quickstart guides by adding histogram‐based distribution logging in both notebook and script examples—introducing sampling utilities, leveraging the Neptune Histogram API in per‐step loops, parameterizing layer count, adding a download_file helper for external assets, and updating notebook content and metadata to reflect the new capabilities.

Class diagram for new and updated utilities in Quickstart

Loading
classDiagram
    class Histogram {
        +bin_edges: np.ndarray
        +counts: np.ndarray
    }
    class Run {
        +log_histograms(histograms: dict, step: int)
        +log_files(files: dict, step: int)
        +log_string_series(data: dict, step: int)
        +assign_files(files: dict)
        +add_tags(tags: list, group_tags: bool)
        +close()
    }
    class QuickstartUtils {
        +get_gradient_norm(layer: int, step: int): float
        +get_activation_distribution(layer: int, step: int): tuple[np.ndarray, np.ndarray]
        +get_gpu_utilization(step: int): float
        +download_file(url: str, filename: str): None
    }
    Run --> Histogram : uses
    QuickstartUtils --> Histogram : creates

File-Level Changes

Change Details Files
Add histogram logging support
  • Define get_activation_distribution function to sample activations
  • Import and instantiate Neptune Histogram type
  • Insert markdown and code cell in notebook to demonstrate log_histograms
  • Add run.log_histograms loop over NUM_STEPS and layers in notebook
  • Extend script main() with run.log_histograms loop using sampled distributions
how-to-guides/quickstart/notebooks/neptune_quickstart.ipynb
how-to-guides/quickstart/scripts/neptune_quickstart.py
Parameterize number of simulated layers
  • Introduce NUM_LAYERS constant in notebook and script
  • Replace hard-coded layer loops (range(10)) with range(NUM_LAYERS)
how-to-guides/quickstart/notebooks/neptune_quickstart.ipynb
how-to-guides/quickstart/scripts/neptune_quickstart.py
Introduce download_file helper for external assets
  • Implement download_file(url, filename) in script
  • Fetch and save sample image, video, and audio before logging
how-to-guides/quickstart/scripts/neptune_quickstart.py
Update notebook content and metadata
  • Expand intro bullets to list new log types (files, string series, histograms)
  • Update notebook kernel spec (display_name and Python version)
  • Adjust dashboard runIdentificationKey URL
  • Refine README and metadata cells to reflect added features
how-to-guides/quickstart/notebooks/neptune_quickstart.ipynb

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

@LeoRoccoBreedt LeoRoccoBreedt marked this pull request as ready for review June 5, 2025 13:55
@LeoRoccoBreedt LeoRoccoBreedt requested a review from a team as a code owner June 5, 2025 13:55
Copy link
Contributor

@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 @LeoRoccoBreedt - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@LeoRoccoBreedt LeoRoccoBreedt self-assigned this Jun 6, 2025
@SiddhantSadangi
Copy link
Member

@LeoRoccoBreedt - left a single comment, and pushed a few changes to account for the latest release:

Summary of code changes:

  • Added data files to gitignore
  • Removed print statement after initializing run as this behavior is now inbuit in neptune_scale
  • Added single-file download snippet to script

Also made some changes to the UI elements:

  • Report:
    • Added histograms to Debugging section
    • Layout updates
  • Saved view:
    • Renamed to My custom view
    • Added the status StringSeries attribute
  • Dashboard:
    • Added FileSeries widget
    • Layout updates

Lemme know what you think

@SiddhantSadangi SiddhantSadangi requested a review from Copilot June 23, 2025 14:51
@SiddhantSadangi
Copy link
Member

@sourcery-ai review

Copy link
Contributor

@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 @LeoRoccoBreedt - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `how-to-guides/quickstart/scripts/neptune_quickstart.py:130` </location>
<code_context>
     )
+
+    # Download sample files
+    response = requests.get(
+        "https://neptune.ai/wp-content/uploads/2024/05/blog_feature_image_046799_8_3_7_3-4.jpg"
+    )
+    response.raise_for_status()
+    with open("sample.png", "wb") as f:
+        f.write(response.content)
+    response = requests.get("https://neptune.ai/wp-content/uploads/2025/05/sac-rl.mp4")
+    response.raise_for_status()
</code_context>

<issue_to_address>
Repeated code for downloading files could be refactored.

Extract the repeated download logic into a helper function for better maintainability.
</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.

Copilot

This comment was marked as outdated.

…nhance logging functionality. Introduced a dedicated `download_file` function for improved code clarity and maintainability.
@SiddhantSadangi SiddhantSadangi requested a review from Copilot June 23, 2025 15:01
@SiddhantSadangi
Copy link
Member

@sourcery-ai review

Copilot

This comment was marked as outdated.

Copy link
Contributor

@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 @LeoRoccoBreedt - I've reviewed your changes - here's some feedback:

  • Consider abstracting the repeated histogram-logging loops into a shared helper to reduce duplication between the notebook and script.
  • Logging histograms on every single step (20k/2k steps) may overwhelm a quickstart; consider sampling or capping steps for demonstration purposes.
  • Please verify that all sample multimedia download URLs (e.g., those with “2025”) are correct and accessible to avoid broken links during the quickstart.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider abstracting the repeated histogram-logging loops into a shared helper to reduce duplication between the notebook and script.
- Logging histograms on every single step (20k/2k steps) may overwhelm a quickstart; consider sampling or capping steps for demonstration purposes.
- Please verify that all sample multimedia download URLs (e.g., those with “2025”) are correct and accessible to avoid broken links during the quickstart.

## Individual Comments

### Comment 1
<location> `how-to-guides/quickstart/scripts/neptune_quickstart.py:65` </location>
<code_context>
     return accuracy, loss


+def download_file(url: str, filename: str) -> None:
+    response = requests.get(url)
+    response.raise_for_status()
</code_context>

<issue_to_address>
Consider adding a timeout to the requests.get call in download_file.

Without a timeout, the function may hang if the server is unresponsive. Adding a timeout will improve reliability.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
def download_file(url: str, filename: str) -> None:
    response = requests.get(url)
    response.raise_for_status()
    with open(filename, "wb") as f:
        f.write(response.content)
=======
def download_file(url: str, filename: str) -> None:
    response = requests.get(url, timeout=10)
    response.raise_for_status()
    with open(filename, "wb") as f:
        f.write(response.content)
>>>>>>> REPLACE

</suggested_fix>

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.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: Siddhant Sadangi <siddhant.sadangi@gmail.com>
@SiddhantSadangi SiddhantSadangi requested a review from Copilot June 23, 2025 15:06
@SiddhantSadangi
Copy link
Member

@sourcery-ai review

Copy link
Contributor

@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 @LeoRoccoBreedt - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `how-to-guides/quickstart/notebooks/neptune_quickstart.ipynb:32` </location>
<code_context>
-    "- Log configuration values and metrics to the run\n"
+    "- Log the following:\n",
+    "    - configuration values and metrics to the run\n",
+    "    - files and series of files\n",
+    "    - logs of custom string series\n",
+    "    - series of histograms"
    ]
   },
</code_context>

<issue_to_address>
The updated guide outline could clarify the distinction between 'files' and 'series of files'.

If there's a specific difference between 'files' and 'series of files', please clarify it in the guide to prevent confusion.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
    "- Log the following:\n",
    "    - configuration values and metrics to the run\n",
    "    - files and series of files\n",
    "    - logs of custom string series\n",
    "    - series of histograms"
=======
    "- Log the following:\n",
    "    - configuration values and metrics to the run\n",
    "    - individual files (e.g., a single model checkpoint or image)\n",
    "    - series of files (e.g., a sequence of model checkpoints or images over epochs)\n",
    "    - logs of custom string series\n",
    "    - series of histograms"
>>>>>>> REPLACE

</suggested_fix>

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.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the Quickstart examples by introducing histogram logging for activation distributions, a helper to download external assets, and parameterizes the number of simulated layers.

  • Add NUM_LAYERS constant and update loops to use it instead of hard-coded values
  • Implement download_file utility and use it to fetch sample assets
  • Introduce histogram logging (series of Histogram objects) in both script and notebook

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
how-to-guides/quickstart/scripts/neptune_quickstart.py Add download_file, NUM_LAYERS, and histogram logging loop; update loops to use NUM_LAYERS
how-to-guides/quickstart/notebooks/neptune_quickstart.ipynb Update notebook to include histogram section, adjust imports and kernel metadata, and parameterize layers
Comments suppressed due to low confidence (3)

how-to-guides/quickstart/scripts/neptune_quickstart.py:185

  • The new histogram logging feature isn't covered by existing tests; consider adding unit or integration tests to verify that log_histograms is called with correct histogram data.
    # Log series of histograms

how-to-guides/quickstart/notebooks/neptune_quickstart.ipynb:544

  • The notebook kernel version is set to Python 3.9.13, which differs from the script's Python 3.12 target. Consider aligning the kernel version to match project requirements for consistency.
   "version": "3.9.13"

how-to-guides/quickstart/notebooks/neptune_quickstart.ipynb:483

  • The trange function is used but not imported in this cell, which will cause a NameError at execution time. Add the appropriate import (e.g., from tqdm import trange).
    "for step in trange(NUM_STEPS):\n",

@SiddhantSadangi SiddhantSadangi requested a review from a team June 23, 2025 15:12
@LeoRoccoBreedt LeoRoccoBreedt changed the title feat: add series of histograms to quickstart Example: update quickstart with latest features Jun 24, 2025
Signed-off-by: Siddhant Sadangi <siddhant.sadangi@neptune.ai>
LeoRoccoBreedt and others added 3 commits June 25, 2025 09:58
Co-authored-by: Sabine Ståhlberg <sabine.stahlberg@neptune.ai>
Signed-off-by: Leo Breedt <101509998+LeoRoccoBreedt@users.noreply.github.com>
Co-authored-by: Sabine Ståhlberg <sabine.stahlberg@neptune.ai>
Signed-off-by: Leo Breedt <101509998+LeoRoccoBreedt@users.noreply.github.com>
@SiddhantSadangi SiddhantSadangi merged commit e532b59 into main Jun 25, 2025
35 checks passed
@SiddhantSadangi SiddhantSadangi deleted the lb/update_quickstart branch June 25, 2025 11:39
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.

3 participants