Skip to content
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

🩹 Fix wrong file loading due to partial filename matching in Project #1212

Merged
merged 7 commits into from
Jan 7, 2023

Conversation

s-weigand
Copy link
Member

@s-weigand s-weigand commented Jan 6, 2023

This PR fixes an issue with using project due to partial matching of file names where the wrong file was loaded if it started with the same string as the intended file, but is higher in the string sorting order.
E.g. if you had 2 files model.yml and model-target.yml in your projects models folder and would call project.load_model("model") it would load model-target.yml.
In addition, some code duplications were removed and error messages for missing files were improved.

Change summary

Checklist

  • ✔️ Passing the tests (mandatory for all PR's)
  • 🚧 Added changes to changelog (mandatory for all PR's)
  • 🧪 Adds new tests for the feature (mandatory for ✨ feature and 🩹 bug fix PR's)

@s-weigand s-weigand requested a review from jsnel as a code owner January 6, 2023 19:42
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2023

Binder 👈 Launch a binder notebook on branch s-weigand/pyglotaran/fix-bad-file-matching-in-project

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 6, 2023

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 1.01%.

Quality metrics Before After Change
Complexity 0.94 ⭐ 0.96 ⭐ 0.02 👎
Method Length 55.54 ⭐ 56.65 ⭐ 1.11 👎
Working memory 6.37 🙂 6.59 🙂 0.22 👎
Quality 78.25% 77.24% -1.01% 👎
Other metrics Before After Change
Lines 1203 1250 47
Changed files Quality Before Quality After Quality Change
glotaran/project/project.py 83.50% ⭐ 82.79% ⭐ -0.71% 👎
glotaran/project/project_registry.py 89.31% ⭐ 89.99% ⭐ 0.68% 👍
glotaran/project/project_result_registry.py 85.23% ⭐ 81.61% ⭐ -3.62% 👎
glotaran/project/test/test_project.py 73.04% 🙂 72.30% 🙂 -0.74% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
glotaran/project/test/test_project.py test_generate_parameters 3 ⭐ 213 ⛔ 9 🙂 56.54% 🙂 Try splitting into smaller methods
glotaran/project/test/test_project.py test_missing_file_errors 0 ⭐ 220 ⛔ 8 🙂 61.27% 🙂 Try splitting into smaller methods
glotaran/project/test/test_project.py test_generators_allow_overwrite 0 ⭐ 151 😞 10 😞 62.82% 🙂 Try splitting into smaller methods. Extract out complex expressions
glotaran/project/test/test_project.py test_run_optimization 2 ⭐ 152 😞 8 🙂 64.98% 🙂 Try splitting into smaller methods
glotaran/project/project.py Project.markdown 0 ⭐ 78 🙂 14 😞 65.54% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@s-weigand s-weigand changed the title 🩹 Fix wrong file loading due to partial matching in Project 🩹 Fix wrong file loading due to partial filename matching in Project Jan 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2023

Benchmark is done. Checkout the benchmark result page.
Benchmark differences below 5% might be due to CI noise.

Benchmark diff v0.6.0 vs. main

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [6c3c390e]       [7dafb8f2]
     <v0.6.0>                   
!      44.7±0.2ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, False)
!      47.5±0.3ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, True)
!      44.8±0.1ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, False)
!      47.5±0.6ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, True)
!      55.3±0.3ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, False)
!       72.1±30ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, True)
!      54.8±0.2ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, False)
!        62.8±3ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, True)
             205M             209M     1.02  IntegrationTwoDatasets.peakmem_optimize
-      1.89±0.02s       1.02±0.03s     0.54  IntegrationTwoDatasets.time_optimize

Benchmark diff main vs. PR

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [7dafb8f2]       [3c26f363]
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, False, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, False, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, True, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, True, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, False, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, False, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, True, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, True, True)
             209M             206M     0.99  IntegrationTwoDatasets.peakmem_optimize
       1.02±0.03s         996±20ms     0.97  IntegrationTwoDatasets.time_optimize

@codecov
Copy link

codecov bot commented Jan 6, 2023

Codecov Report

Base: 87.7% // Head: 87.7% // No change to project coverage 👍

Coverage data is based on head (7dafb8f) compared to base (7dafb8f).
Patch has no changes to coverable lines.

❗ Current head 7dafb8f differs from pull request most recent head 3c26f36. Consider uploading reports for the commit 3c26f36 to get more accurate results

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1212   +/-   ##
=====================================
  Coverage   87.7%   87.7%           
=====================================
  Files        104     104           
  Lines       4968    4968           
  Branches     824     824           
=====================================
  Hits        4359    4359           
  Misses       492     492           
  Partials     117     117           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@jsnel jsnel left a comment

Choose a reason for hiding this comment

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

LGTM!

@s-weigand s-weigand merged commit ec4a90c into glotaran:main Jan 7, 2023
@s-weigand s-weigand deleted the fix-bad-file-matching-in-project branch January 7, 2023 19:52
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