Skip to content

Test: Added CondaFlowDecorator unit tests#3193

Merged
talsperre merged 7 commits into
Netflix:masterfrom
agsaru:conda_test
May 31, 2026
Merged

Test: Added CondaFlowDecorator unit tests#3193
talsperre merged 7 commits into
Netflix:masterfrom
agsaru:conda_test

Conversation

@agsaru

@agsaru agsaru commented May 12, 2026

Copy link
Copy Markdown
Contributor

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

greptile-apps Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug in CondaFlowDecorator.init() where user-defined packages were not being tracked in _attributes_with_user_values, and expands the test suite to cover both decorator classes with parametrized pytest functions.

  • Bug fix: CondaFlowDecorator.init() now adds \"packages\" to _attributes_with_user_values when the merged packages dict is non-empty, making it consistent with the identical logic already in CondaStepDecorator.init().
  • Tests restructured: The old class-based TestCondaStepDecorator and the separate test/unit/test_conda_decorator.py are replaced by a single parametrized test module that exercises both decorator classes across default attributes, python tracking, packages tracking, libraries backward-compat merging, disabled flag, and packages-takes-precedence-over-libraries semantics.

Confidence Score: 5/5

Safe to merge — the production change is a two-line addition that makes CondaFlowDecorator symmetric with CondaStepDecorator, and the tests correctly validate all affected code paths.

The fix is minimal and clearly correct: it replicates a pattern already present and well-tested in CondaStepDecorator. All new tests exercise both decorator classes and cover the merge semantics, precedence rules, and user-tracking logic introduced by the fix.

No files require special attention.

Important Files Changed

Filename Overview
metaflow/plugins/pypi/conda_decorator.py Two-line bug fix in CondaFlowDecorator.init() to track user-defined packages in _attributes_with_user_values, mirroring the identical logic already present in CondaStepDecorator.init().
test/plugins/conda/test_conda_decorator_unit.py Expanded and restructured test file; old class-based tests replaced by parametrized pytest functions covering both CondaStepDecorator and CondaFlowDecorator, including a new packages-precedence test case.
test/unit/test_conda_decorator.py Deleted; its two test cases are fully covered by the new parametrized tests in test/plugins/conda/test_conda_decorator_unit.py.

Reviews (5): Last reviewed commit: "Clean up conda decorator tests" | Re-trigger Greptile

Comment thread test/plugins/conda/test_conda_decorator_unit.py Outdated

Copilot AI 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.

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

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

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.33%           
=========================================
  Files             ?      381           
  Lines             ?    52355           
  Branches          ?     9243           
=========================================
  Hits              ?    14833           
  Misses            ?    36582           
  Partials          ?      940           

☔ 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.

Copilot AI 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.

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"""
@talsperre
talsperre merged commit 703844a into Netflix:master May 31, 2026
41 checks passed
@agsaru
agsaru deleted the conda_test branch June 10, 2026 17:38
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