Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coyote
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nils
coyote
Commits
bcc62421
Commit
bcc62421
authored
1 month ago
by
Nils-Arne Dreier
Browse files
Options
Downloads
Patches
Plain Diff
fix: avoid reopen the zarr again and again
parent
6a558e1b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#101571
waiting for manual action
Stage: lint
Stage: build
Stage: test
Stage: verify
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/hiopy/_zarr_utils.py
+7
-6
7 additions, 6 deletions
apps/hiopy/_zarr_utils.py
apps/hiopy/worker.py
+4
-3
4 additions, 3 deletions
apps/hiopy/worker.py
with
11 additions
and
9 deletions
apps/hiopy/_zarr_utils.py
+
7
−
6
View file @
bcc62421
...
...
@@ -2,16 +2,17 @@ import zarr
def
get_var_group
(
v
):
z
=
zarr
.
open
(
v
.
store
)
parent_group_path
=
"
/
"
.
join
(
v
.
path
.
split
(
"
/
"
)[:
-
1
])
if
parent_group_path
==
""
:
return
z
if
not
hasattr
(
v
,
"
root
"
):
v
.
root
=
zarr
.
open
(
v
.
store
)
group_path
=
"
/
"
.
join
(
v
.
path
.
split
(
"
/
"
)[:
-
1
])
if
group_path
==
""
:
return
v
.
root
else
:
return
z
[
parent_
group_path
]
return
v
.
root
[
group_path
]
def
get_var_parent_group
(
v
):
var_group
=
get_var_group
(
v
)
parent_var_path
=
var_group
.
attrs
[
"
hiopy::parent
"
]
parent_group
=
zarr
.
open
(
v
.
store
)
[
parent_var_path
]
parent_group
=
v
.
root
[
parent_var_path
]
return
parent_group
This diff is collapsed.
Click to expand it.
apps/hiopy/worker.py
+
4
−
3
View file @
bcc62421
...
...
@@ -79,14 +79,15 @@ def main():
)
# find all variables considered to be written in the input datasets:
def
collect_data_vars
(
group
):
def
collect_data_vars
(
group
,
root
):
for
_name
,
item
in
group
.
arrays
():
if
"
hiopy::enable
"
in
item
.
attrs
and
item
.
attrs
[
"
hiopy::enable
"
]:
item
.
root
=
root
yield
item
for
_name
,
item
in
group
.
groups
():
yield
from
collect_data_vars
(
item
)
yield
from
collect_data_vars
(
item
,
root
)
all_data_vars
=
list
(
chain
(
*
[
collect_data_vars
(
z
)
for
z
in
args
.
datasets
]))
all_data_vars
=
list
(
chain
(
*
[
collect_data_vars
(
z
,
z
)
for
z
in
args
.
datasets
]))
logging
.
info
(
f
"
Found
{
len
(
all_data_vars
)
}
variables
"
)
if
len
(
all_data_vars
)
==
0
:
raise
RuntimeError
(
"
No variables found by the hiopy worker.
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment