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

✨ Allow import of xarray objects in project API import_data #1235

Merged
merged 2 commits into from
Feb 11, 2023

Conversation

s-weigand
Copy link
Member

@s-weigand s-weigand commented Feb 10, 2023

This makes data importing with the project API more flexible by allowing direct import from xarray.Dataset or xarray.DataArray.

from glotaran.project import Project

project = Project.open("my_project")

# my_custom_load_function returns a `xarray.Dataset` or `xarray.DataArray`
my_dataset = my_custom_load_function("dataset.foobar")

project.import_data(my_dataset , name="my_dataset ")

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 February 10, 2023 20:22
@github-actions
Copy link
Contributor

Binder 👈 Launch a binder notebook on branch s-weigand/pyglotaran/project-allow-import-from-xarray

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 10, 2023

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 0.88 ⭐ 1.08 ⭐ 0.20 👎
Method Length 68.00 🙂 70.41 🙂 2.41 👎
Working memory 6.71 🙂 6.75 🙂 0.04 👎
Quality 75.25% 74.48% 🙂 -0.77% 👎
Other metrics Before After Change
Lines 1207 1259 52
Changed files Quality Before Quality After Quality Change
glotaran/project/project.py 83.40% ⭐ 83.52% ⭐ 0.12% 👍
glotaran/project/project_data_registry.py 74.38% 🙂 61.94% 🙂 -12.44% 👎
glotaran/project/test/test_project.py 72.64% 🙂 72.27% 🙂 -0.37% 👎

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/project_data_registry.py ProjectDataRegistry.import_data 9 🙂 123 😞 10 😞 57.22% 🙂 Try splitting into smaller methods. Extract out complex expressions
glotaran/project/test/test_project.py test_missing_file_errors 0 ⭐ 276 ⛔ 8 🙂 58.36% 🙂 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

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!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 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]       [18c17306]
     <v0.6.0>                   
!      43.8±0.5ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, False)
!      47.6±0.3ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, True)
!      43.7±0.9ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, False)
!      47.6±0.4ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, True)
!        55.6±1ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, False)
!       58.9±40ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, True)
!        57.0±3ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, False)
!       59.8±20ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, True)
             203M             204M     1.00  IntegrationTwoDatasets.peakmem_optimize
-      1.77±0.04s       1.13±0.03s     0.64  IntegrationTwoDatasets.time_optimize

Benchmark diff main vs. PR

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [18c17306]       [73f98af6]
           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)
             204M             207M     1.01  IntegrationTwoDatasets.peakmem_optimize
       1.13±0.03s       1.09±0.04s     0.96  IntegrationTwoDatasets.time_optimize

jsnel
jsnel previously approved these changes Feb 10, 2023
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.

Looks good to me. 😀

@codecov
Copy link

codecov bot commented Feb 10, 2023

Codecov Report

Base: 87.9% // Head: 87.9% // Decreases project coverage by -0.1% ⚠️

Coverage data is based on head (73f98af) compared to base (18c1730).
Patch coverage: 88.2% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1235     +/-   ##
=======================================
- Coverage   87.9%   87.9%   -0.1%     
=======================================
  Files        104     104             
  Lines       5010    5019      +9     
  Branches     833     837      +4     
=======================================
+ Hits        4407    4414      +7     
- Misses       487     488      +1     
- Partials     116     117      +1     
Impacted Files Coverage Δ
glotaran/project/project.py 98.5% <60.0%> (-1.5%) ⬇️
glotaran/project/project_data_registry.py 100.0% <100.0%> (ø)

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.

@s-weigand s-weigand enabled auto-merge February 10, 2023 21:17
@s-weigand s-weigand force-pushed the project-allow-import-from-xarray branch 2 times, most recently from c38e1fd to d2296bc Compare February 10, 2023 21:31
@s-weigand s-weigand force-pushed the project-allow-import-from-xarray branch from d2296bc to 73f98af Compare February 10, 2023 21:32
@sonarqubecloud
Copy link

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

auto-merge was automatically disabled February 10, 2023 22:10

Merge queue setting changed

@jsnel jsnel merged commit 606e8f3 into glotaran:main Feb 11, 2023
@jsnel jsnel deleted the project-allow-import-from-xarray branch February 11, 2023 12: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.

2 participants