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

🩹 False positive model validation fail when combining multiple default megacomplexes #797

Merged

Conversation

s-weigand
Copy link
Member

@s-weigand s-weigand commented Aug 29, 2021

This PR is just preventing the false-negative validation and not fixing the root cause of the problem.

Change summary

  • Fix error formatting (missing f in format string)
  • Improves typing
  • Adds unittests for DatasetModel.ensure_unique_megacomplexes
  • Fixes missing report when megacomplex isn't defined
  • Fixes megacompley type being None
  • Refactored DatasetModel.ensure_unique_megacomplexes to use counter for uniqueness checking

Checklist

  • ✔️ Passing the tests (mandatory for all PR's)
  • 👌 Closes issue (mandatory for ✨ feature and 🩹 bug fix PR's)
  • 🧪 Adds new tests for the feature (mandatory for ✨ feature and 🩹 bug fix PR's)

Closes issues

closes #796

@s-weigand s-weigand added Type: Serious Bug Crashes, Broken code, Security Issues Type: Bug Minor issues, non-crashing bug, slowdowns labels Aug 29, 2021
@github-actions
Copy link
Contributor

Binder 👈 Launch a binder notebook on branch s-weigand/pyglotaran/fix-missing-f-in-f-string-error-format

@codecov
Copy link

codecov bot commented Aug 29, 2021

Codecov Report

Merging #797 (dee11fc) into staging (70a1205) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           staging    #797   +/-   ##
=======================================
  Coverage     84.4%   84.4%           
=======================================
  Files           75      75           
  Lines         4196    4195    -1     
  Branches       758     755    -3     
=======================================
+ Hits          3542    3544    +2     
+ Misses         520     518    -2     
+ Partials       134     133    -1     
Impacted Files Coverage Δ
glotaran/model/dataset_model.py 82.0% <100.0%> (+1.6%) ⬆️
glotaran/model/megacomplex.py 98.5% <100.0%> (+1.4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70a1205...dee11fc. Read the comment docs.

@s-weigand s-weigand changed the title 🩹 Partial hotfix for #796 🩹 False positive model validation fail when combining multiple default megacomplexes Aug 29, 2021
@s-weigand s-weigand force-pushed the fix-missing-f-in-f-string-error-format branch 2 times, most recently from 0719076 to a80b61e Compare August 29, 2021 20:07
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!

Copy link
Member

@joernweissenborn joernweissenborn left a comment

Choose a reason for hiding this comment

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

lgtm

Compatibility with legacy (0.4.0) model specs and combining multiple megacomplexes
And improved typing.

Since 'DatasetModel' is never instantiated from the class definition, but 'create_dataset_model_type' creates a new class in a closure each time a new instance is needed, values across instances won't be overwritten.
After a personal request of @joernweissenborn  I removed the class attributes again and moved them to a pyi file
Since it is already reported as 'Missing Model Item'
@jsnel jsnel force-pushed the fix-missing-f-in-f-string-error-format branch from a80b61e to dee11fc Compare September 3, 2021 20:22
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 3, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 5.83 ⭐ 5.80 ⭐ -0.03 👍
Method Length 32.08 ⭐ 32.75 ⭐ 0.67 👎
Working memory 7.45 🙂 7.44 🙂 -0.01 👍
Quality 72.79% 🙂 72.53% 🙂 -0.26% 👎
Other metrics Before After Change
Lines 133 135 2
Changed files Quality Before Quality After Quality Change
glotaran/model/megacomplex.py 72.79% 🙂 72.53% 🙂 -0.26% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
glotaran/model/megacomplex.py _add_model_items_to_properties 11 🙂 96 🙂 12 😞 55.31% 🙂 Extract out complex expressions
glotaran/model/megacomplex.py megacomplex 9 🙂 136 😞 9 🙂 57.74% 🙂 Try splitting into smaller methods

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!

@sonarcloud
Copy link

sonarcloud bot commented Sep 3, 2021

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2021

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

Benchmark diff

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [dc00e6da]       [dee11fc8]
     <v0.4.0>                   
-        68.1±1ms         46.3±1ms     0.68  BenchmarkOptimize.time_optimize(False, False, False)
-        382±10ms         60.8±2ms     0.16  BenchmarkOptimize.time_optimize(False, False, True)
-      91.6±0.8ms         80.2±1ms     0.88  BenchmarkOptimize.time_optimize(False, True, False)
         91.4±2ms         88.0±3ms     0.96  BenchmarkOptimize.time_optimize(False, True, True)
         65.7±1ms         61.8±3ms     0.94  BenchmarkOptimize.time_optimize(True, False, False)
-         385±5ms        71.2±30ms     0.19  BenchmarkOptimize.time_optimize(True, False, True)
         95.7±2ms         94.5±4ms     0.99  BenchmarkOptimize.time_optimize(True, True, False)
         97.5±2ms         105±10ms     1.08  BenchmarkOptimize.time_optimize(True, True, True)
             180M             181M     1.01  IntegrationTwoDatasets.peakmem_create_result
             199M             199M     1.00  IntegrationTwoDatasets.peakmem_optimize
-        291±10ms          221±5ms     0.76  IntegrationTwoDatasets.time_create_result
-      5.85±0.01s       1.52±0.05s     0.26  IntegrationTwoDatasets.time_optimize

jsnel pushed a commit that referenced this pull request Sep 16, 2021
…t megacomplexes (#797)

* 🩹 Fixed missing 'f' in front of f-string which rendered the error useless

* 🩹 Deactivate instance check if megacomplex type is None

Compatibility with legacy (0.4.0) model specs and combining multiple megacomplexes

* 🩹 Fixed usage of  'glotaran_unique' in 'ensure_unique_megacomplexes'

* 👌 Improved typing

* 🧪 Added unittests for 'ensure_unique_megacomplexes'

* 🩹 Fixed missing megacomplex definition not being reported as error

* 🩹 Fixed megacomplex type being None

* ♻️ Refactored 'ensure_unique_megacomplexes' using Counter and improved typing.
Since 'DatasetModel' is never instantiated from the class definition, but 'create_dataset_model_type' creates a new class in a closure each time a new instance is needed, values across instances won't be overwritten.

* ♻️ Moved typing information to stub file
After a personal request of @joernweissenborn  I removed the class attributes again and moved them to a pyi file

* 🧹 Removed warning about missing megacomplex definition
Since it is already reported as 'Missing Model Item'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Minor issues, non-crashing bug, slowdowns Type: Serious Bug Crashes, Broken code, Security Issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants