-
Notifications
You must be signed in to change notification settings - Fork 19
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
Precompiling script for improving YAXArrays precompilation #271
Open
linamaes
wants to merge
1
commit into
master
Choose a base branch
from
precompile_script
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using PrecompileTools | ||
|
||
@recompile_invalidations begin | ||
# load packages | ||
using Dates | ||
using Statistics | ||
using Zarr | ||
end | ||
|
||
|
||
@setup_workload begin | ||
# Putting some things in `@setup_workload` instead of `@compile_workload` can reduce the size of the | ||
# precompile file and potentially make loading faster. | ||
@compile_workload begin | ||
z0 = YAXArray(rand(10,10)) | ||
nameout = string(tempname(),".zarr") | ||
z0 = YAXArray(rand(10,10)) | ||
z1 = zcreate(Float64, 10,10, path=nameout) | ||
z1 .= z0[:,:] | ||
|
||
|
||
|
||
|
||
#savecube(z0, nameout) | ||
# c = Cube(nameout) | ||
# show(c[1,1]) | ||
# show(c[1,1:3]) | ||
# show(c[2,1:3]) | ||
# show(c) | ||
# csum = mapslices(sum, c, dims="Dim_1") | ||
# cmean = mapslices(mean, c, dims="Dim_1") | ||
|
||
|
||
# z0 = YAXArray(rand(10,10)) | ||
# nameout = string(tempname(),".zarr") | ||
# z1 = zcreate(Float64, 10,10, path=nameout) | ||
# z1 .= z0[:,:] | ||
# z2 = zopen(nameout) | ||
# show(z2[1,1]) | ||
# show(z2[1,1:3]) | ||
# show(z2[2,1:3]) | ||
# show(z2) | ||
# zsum = mapslices(sum, z2, dims=1) | ||
# zmean = mapslices(mean, z2, dims=2) | ||
|
||
|
||
# a = YAXArray(rand(10,10)) | ||
# show(a[1,1]) | ||
# show(a[Dim_1=1..3]) | ||
# show(a[Dim_2=1..3]) | ||
# show(a) | ||
# a1 = mapslices(sum, a, dims="Dim_1") | ||
# a3 = mapslices(mean, a, dims="Dim_2") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Pkg | ||
|
||
using PrecompileTools | ||
|
||
@recompile_invalidations begin | ||
# load packages | ||
using Dates | ||
using Statistics | ||
using Zarr | ||
# using YAXArrays | ||
end | ||
|
||
|
||
@setup_workload begin | ||
# Putting some things in `@setup_workload` instead of `@compile_workload` can reduce the size of the | ||
# precompile file and potentially make loading faster. | ||
@compile_workload begin | ||
|
||
t = Date("2020-01-01"):Month(1):Date("2022-12-31") | ||
|
||
## create cube axes | ||
axes = [RangeAxis("Lon", 1:10), RangeAxis("Lat", 1:10), RangeAxis("Time", t)] | ||
|
||
## assign values to a cube | ||
z0 = YAXArray(axes, reshape(1:3600, (10,10,36))) | ||
|
||
# saving and opening Zarr files | ||
nameout = string(tempname(),".zarr") | ||
z1 = zcreate(Float64, 10,10,36, path=nameout) | ||
z1 .= z0[:,:,:] | ||
z2 = zopen(nameout) | ||
|
||
# simple data visualization | ||
show(z2[1,1,1]) | ||
show(z2[1,1:3,1]) | ||
show(z2[2,1:3,1]) | ||
show(z2) | ||
|
||
# simple statistics across different axes | ||
zsum = mapslices(sum, z2, dims=1) | ||
zmean = mapslices(mean, z2, dims=2) | ||
zmean = mapslices(mean, z2, dims=3) | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would add Zarr and NetCDF as direct dependencies to the package. @felixcremer we should discuss how to deal with this. Maybe we could add them as weakdeps and only do the precompilation if these packages are in the environment?