Skip to content

Test: Added CondaFlowDecorator unit tests#3193

Open
agsaru wants to merge 6 commits into
Netflix:masterfrom
agsaru:conda_test
Open

Test: Added CondaFlowDecorator unit tests#3193
agsaru wants to merge 6 commits into
Netflix:masterfrom
agsaru:conda_test

Conversation

@agsaru
Copy link
Copy Markdown
Contributor

@agsaru agsaru commented May 12, 2026

PR Type

  • Bug fix
  • New feature
  • Core Runtime change (higher bar -- see CONTRIBUTING.md)
  • Docs / tooling
  • Refactoring

Summary

This PR adds unit tests for the CondaFlowDecorator and expands the existing tests for CondaStepDecorator. It also includes a minor bug fix in CondaFlowDecorator to ensure user-defined packages are properly tracked.

  • Updated CondaFlowDecorator to correctly track user-defined packages.
  • Added unit tests for CondaFlowDecorator.
  • Added a new test in TestCondaStepDecorator for packages correctly take precedence over libraries.

Tests

  • Unit tests added/updated
  • Reproduction script provided (required for Core Runtime)
  • CI passes
  • If tests are impractical: explain why below and provide manual evidence above

Copilot AI review requested due to automatic review settings May 12, 2026 16:50
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 12, 2026

Greptile Summary

This PR fixes a bug in CondaFlowDecorator.init() where user-provided packages were not being tracked in _attributes_with_user_values after the librariespackages merge, and adds a comprehensive TestCondaFlowDecorator test class alongside incremental improvements to the existing TestCondaStepDecorator suite.

  • Bug fix (conda_decorator.py): Two lines are added to CondaFlowDecorator.init() so that packages is added to _attributes_with_user_values whenever the merged result is non-empty — exactly mirroring the logic already present in CondaStepDecorator.init().
  • New tests (test_conda_decorator_unit.py): TestCondaFlowDecorator covers defaults, user-defined python, packages, libraries backward-compat, merge, and precedence. TestCondaStepDecorator gains explicit value assertions and a new test_packages_precedence case.
  • Cleanup (test/unit/test_conda_decorator.py): The old standalone test file is deleted; its coverage is fully superseded by the expanded class-based tests.

Confidence Score: 5/5

Safe to merge — the production change is a two-line addition that mirrors already-proven logic in the sibling decorator, and the new tests directly validate the fixed behaviour.

The production change is minimal and targeted: it adds the same _attributes_with_user_values tracking that CondaStepDecorator.init() already had, applied symmetrically to CondaFlowDecorator.init(). All new and updated tests are logically correct and directly exercise the fixed path.

No files require special attention.

Important Files Changed

Filename Overview
metaflow/plugins/pypi/conda_decorator.py Adds two lines to CondaFlowDecorator.init() so packages is tracked in _attributes_with_user_values after the libraries→packages merge — mirrors the identical logic that already existed in CondaStepDecorator.init()
test/plugins/conda/test_conda_decorator_unit.py Expands the existing TestCondaStepDecorator suite with value-assertion lines and a new packages-precedence test; adds a new TestCondaFlowDecorator class covering defaults, user-defined python, packages, libraries backward compat, merge, and precedence
test/unit/test_conda_decorator.py Old standalone test file deleted; its two test functions are fully superseded by the expanded test class in test/plugins/conda/test_conda_decorator_unit.py

Reviews (4): Last reviewed commit: "Merge branch 'conda_test' of https://git..." | Re-trigger Greptile

Comment thread test/plugins/conda/test_conda_decorator_unit.py
Copy link
Copy Markdown
Contributor

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

Adds unit-level coverage for conda decorators’ attribute normalization/user-defined tracking, and fixes CondaFlowDecorator so legacy libraries inputs correctly mark packages as user-defined after merging.

Changes:

  • Fix: CondaFlowDecorator.init() now marks packages as user-defined when legacy libraries populates it.
  • Tests: Expand CondaStepDecorator unit assertions (merge behavior, precedence, and normalization).
  • Tests: Add a new TestCondaFlowDecorator suite covering defaults, user-defined tracking, merge behavior, and precedence.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/plugins/conda/test_conda_decorator_unit.py Adds/expands pure unit tests for CondaStepDecorator and CondaFlowDecorator covering merge/preference and user-defined tracking.
metaflow/plugins/pypi/conda_decorator.py Bug fix to ensure flow-level packages is treated as user-defined when derived from legacy libraries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/plugins/conda/test_conda_decorator_unit.py Outdated
@agsaru agsaru marked this pull request as draft May 12, 2026 17:03
@agsaru agsaru marked this pull request as ready for review May 12, 2026 17:08
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@6d509db). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3193   +/-   ##
=========================================
  Coverage          ?   28.30%           
=========================================
  Files             ?      381           
  Lines             ?    52344           
  Branches          ?     9239           
=========================================
  Hits              ?    14815           
  Misses            ?    36591           
  Partials          ?      938           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

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

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

Comments suppressed due to low confidence (1)

test/plugins/conda/test_conda_decorator_unit.py:111

  • Docstring grammar nit: "'packages' and 'libraries' attribute have" should be pluralized/reworded for clarity (e.g., "When both attributes specify the same package, 'packages' takes precedence.").
    def test_packages_precedence(self):
        """When both 'packages' and 'libraries' attribute have same packages, 'packages' attribute takes precedence."""
        deco = CondaFlowDecorator(

Comment on lines +67 to +73
def test_default_attributes(self):
deco = CondaFlowDecorator()
deco.init()
assert deco.attributes["packages"] == {}
assert deco.attributes["python"] is None
assert not deco.attributes["disabled"]

assert deco.attributes["libraries"] == {}

def test_packages_precedence(self):
"""When both 'packages' and 'libraries' attribute have same packages, 'packages' attribute takes precedence"""
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