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

✨ Add Folder plugin for save result #620

Merged
merged 5 commits into from Mar 29, 2021
Merged

Conversation

s-weigand
Copy link
Member

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

This plugin adds back the functionality from glotaran.analysis.result.Result.save(result_path) of pyglotaran 0.3.x.
For glotaran.io.save_result it also adds inferring of format_name=="folder" if the provided result_path doesn't have an extension.
If result_path is a file it will raise a ValueError.

Usage equivalent to result.save(result_path)

save_result(result_path=str(output_folder), result=result, allow_overwrite=True)
# or if format must be given:
save_result(result_path=str(output_folder), result=result, format_name="folder", allow_overwrite=True)
save_result(result_path=str(output_folder), result=result, format_name="pyglotaran-legacy", allow_overwrite=True)

Also, the plugin is registered under the names folder and pyglotaran-legacy, thus if we want to fundamentally change the folder-plugin we can keep the old implementation around as pyglotaran-legacy for backward compatibility.

Testing

Passing the tests is mandatory.

Closing issues

closes #619

@s-weigand s-weigand requested a review from a team as a code owner March 29, 2021 00:46
@codecov
Copy link

codecov bot commented Mar 29, 2021

Codecov Report

Merging #620 (826555e) into main (b188047) will increase coverage by 0.1%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #620     +/-   ##
=======================================
+ Coverage   77.8%   78.0%   +0.1%     
=======================================
  Files         63      64      +1     
  Lines       3537    3564     +27     
  Branches     658     663      +5     
=======================================
+ Hits        2753    2781     +28     
+ Misses       655     654      -1     
  Partials     129     129             
Impacted Files Coverage Δ
glotaran/builtin/io/folder/folder_plugin.py 100.0% <100.0%> (ø)
glotaran/plugin_system/io_plugin_utils.py 100.0% <100.0%> (ø)
glotaran/plugin_system/project_io_registration.py 100.0% <100.0%> (ø)
glotaran/parameter/parameter_group.py 88.6% <0.0%> (+0.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 b188047...826555e. Read the comment docs.

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.

Tested OK.

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.

Please change 'pyglotaran-legacy' to 'legacy' in the context of pyglotaran plugins that should be sufficient.

If we decide to change the folder plugin we can still keep 'legacy' for compatibility or in the long run make it a stand alone plugin.
Added tests for folder plugin where result_path is an existing file without an extension.
That way it can be imported and by tests and there is less code duplication.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 29, 2021

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 4.85%.

Quality metrics Before After Change
Complexity 1.53 ⭐ 1.12 ⭐ -0.41 👍
Method Length 34.65 ⭐ 31.37 ⭐ -3.28 👍
Working memory 6.77 🙂 5.80 ⭐ -0.97 👍
Quality 82.70% 87.55% 4.85% 👍
Other metrics Before After Change
Lines 732 738 6
Changed files Quality Before Quality After Quality Change
glotaran/builtin/io/yml/test/test_save_result.py 47.52% 😞 85.79% ⭐ 38.27% 👍
glotaran/plugin_system/io_plugin_utils.py 84.39% ⭐ 82.41% ⭐ -1.98% 👎
glotaran/plugin_system/project_io_registration.py 86.84% ⭐ 86.66% ⭐ -0.18% 👎
glotaran/plugin_system/test/test_io_plugin_utils.py 92.70% ⭐ 92.19% ⭐ -0.51% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
glotaran/plugin_system/io_plugin_utils.py protect_from_overwrite 4 ⭐ 52 ⭐ 11 😞 70.29% 🙂 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!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@sonarcloud
Copy link

sonarcloud bot commented Mar 29, 2021

Kudos, SonarCloud 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

@s-weigand
Copy link
Member Author

Admittedly the importing of the fixture and that for added noqas look a bit ugly, but since the tests are inside of the package and not in a separate folder we can just use a global conftest.py so all fixtures are known to all pytest tests.

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. More✨ for pyglotaran

@jsnel jsnel merged commit 2c63ae3 into glotaran:main Mar 29, 2021
@jsnel jsnel deleted the folder-plugin branch March 29, 2021 18:11
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.

save_result needs a folder plugin
2 participants