Skip to content

Commit 4c50302

Browse files
authored
Merge branch 'main' into forman-56-no_gobal_attrs
2 parents bd7a3f0 + b654f6f commit 4c50302

File tree

11 files changed

+155
-21
lines changed

11 files changed

+155
-21
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Describe how to reproduce the behavior.
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Python Environment**
20+
- operating system:
21+
- zappend version, output of `zappend --version`:
22+
- optional: packages and their versions, output of `pip list` or `conda list`:
23+
24+
**Additional context**
25+
Add any other context about the problem here.
26+
27+
**Traceback**
28+
If applicable, add a traceback of your error here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Description of PR]
2+
3+
Checklist (strike out non-applicable):
4+
5+
* [ ] Changes documented in `CHANGES.md`
6+
* [ ] Related issue exists and is referred to in the PR description and `CHANGES.md`
7+
* [ ] Added docstrings and API docs for any new/modified user-facing classes and functions
8+
* [ ] Changes/features documented in `docs/*`
9+
* [ ] Unit-tests adapted/added for changes/features
10+
* [ ] Test coverage remains or increases (target 100%)

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
* Global metadata attributes of target dataset is no longer empty. [#56]
66

7+
* If the target _parent_ directory did not exist, an exception was raised
8+
reporting that the lock file to be written does not exist. Changed this to
9+
report that the target parent directory does not exist. [#55]
10+
11+
### Enhancements
12+
13+
* Added missing documentation of the `append_step` setting in the
14+
[configuration reference](https://bcdev.github.io/zappend/config/).
15+
716
## Version 0.4.0 (from 2024-02-08)
817

918
### Enhancements

SECURITY.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 0.4.x | :white_check_mark: |
8+
| < 0.4 | :x: |
9+
10+
## Reporting a Vulnerability
11+
12+
To report a vulnerability, please post and [issue](https://github.com/bcdev/zappend/issues)
13+
and use prefix `[SECURITY]` for the title. Security issues will be treated with high priority.

docs/config.md

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
## `version`
55

66
Configuration schema version. Allows the schema to evolve while still preserving backwards compatibility.
7-
Its value must be `1`.
7+
Its value is `1`.
88
Defaults to `1`.
99

1010
## `zarr_version`
1111

1212
The Zarr version to be used.
13-
Its value must be `2`.
13+
Its value is `2`.
1414
Defaults to `2`.
1515

1616
## `fixed_dims`
@@ -25,6 +25,28 @@ Type _string_.
2525
The name of the variadic append dimension.
2626
Defaults to `"time"`.
2727

28+
## `append_step`
29+
30+
If set, enforces a step size in the append dimension between two slices or just enforces a direction.
31+
Must be one of the following:
32+
33+
* Arbitrary step size or not applicable.
34+
Its value is `null`.
35+
36+
* Monotonically increasing.
37+
Its value is `"+"`.
38+
39+
* Monotonically decreasing.
40+
Its value is `"-"`.
41+
42+
* Type _string_.
43+
A positive or negative time delta value, such as `12h`, `2D`, `-1D`.
44+
45+
* Type _number_.
46+
A positive or negative numerical delta value.
47+
48+
Defaults to `null`.
49+
2850
## `included_variables`
2951

3052
Type _array_.
@@ -59,27 +81,29 @@ Variable metadata.
5981

6082
* `chunks`:
6183
Storage chunking.
62-
Must be one of the following.
84+
Must be one of the following:
6385

6486
* Type _array_.
6587
Chunk sizes in the order of the dimensions.
6688
The items of the array are of type _integer_.
6789

6890
* Disable chunking.
69-
Its value must be `null`.
91+
Its value is `null`.
92+
7093

7194
* `fill_value`:
7295
Storage fill value.
73-
Must be one of the following.
96+
Must be one of the following:
7497

7598
* Type _number_.
7699
A number of type and unit of the given storage `dtype`.
77100

78101
* Not-a-number. Can be used only if storage `dtype` is `float32` or `float64`.
79-
Its value must be `"NaN"`.
102+
Its value is `"NaN"`.
80103

81104
* No fill value.
82-
Its value must be `null`.
105+
Its value is `null`.
106+
83107

84108
* `scale_factor`:
85109
Type _number_.
@@ -122,7 +146,7 @@ Variable metadata.
122146
## `target_dir`
123147

124148
Type _string_.
125-
The URI or local path of the target Zarr dataset. Must be a directory.
149+
The URI or local path of the target Zarr dataset. Must specify a directory whose parent directory must exist.
126150

127151
## `target_storage_options`
128152

@@ -147,13 +171,13 @@ Options for the filesystem given by the protocol of the URIs of contributing dat
147171
## `slice_polling`
148172

149173
Defines how to poll for contributing datasets.
150-
Must be one of the following.
174+
Must be one of the following:
151175

152176
* No polling, fail immediately if dataset is not available.
153-
Its value must be `false`.
177+
Its value is `false`.
154178

155179
* Poll using default values.
156-
Its value must be `true`.
180+
Its value is `true`.
157181

158182
* Type _object_.
159183
Polling parameters.
@@ -169,6 +193,7 @@ Must be one of the following.
169193
Polling timeout in seconds.
170194
Defaults to `60`.
171195

196+
172197
## `persist_mem_slices`
173198

174199
Type _boolean_.
@@ -194,7 +219,7 @@ Defaults to `false`.
194219
## `profiling`
195220

196221
Profiling configuration. Allows for runtime profiling of the processing.
197-
Must be one of the following.
222+
Must be one of the following:
198223

199224
* Type _boolean_.
200225
If set, profiling is enabled and output is logged using level `"INFO"`. Otherwise, profiling is disabled.
@@ -227,7 +252,7 @@ Must be one of the following.
227252
* `restrictions`:
228253
Type _array_.
229254
Used to limit the list down to the significant entries in the profiling report. Refer to [Stats.print_stats(*restrictions)](https://docs.python.org/3/library/profile.html#pstats.Stats.print_stats).
230-
The items of the array must be one of the following.
255+
The items of the array must be one of the following:
231256

232257
* Type _integer_.
233258
Select a count of lines.
@@ -237,6 +262,8 @@ Must be one of the following.
237262

238263
* Type _string_.
239264
Pattern-match the standard name that is printed.
265+
266+
240267

241268
## `logging`
242269

@@ -246,7 +273,7 @@ The key `version` is required.
246273

247274
* `version`:
248275
Logging schema version.
249-
Its value must be `1`.
276+
Its value is `1`.
250277

251278
* `formatters`:
252279
Type _object_.

docs/guide.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ zappend(os.listdir("inputs"), target_dir="output/mycube.zarr")
1616

1717
Both invocations will create the Zarr dataset `output/mycube.zarr` by concatenating
1818
the "slice" datasets provided in the `inputs` directory along their `time` dimension.
19-
Both the CLI command and the Python function can be run without any further
19+
`target_dir` must specify a directory for the Zarr dataset. (Its parent directory must
20+
exist.) Both the CLI command and the Python function can be run without any further
2021
configuration provided the paths of the target dataset and the source slice datasets
2122
are given. The target dataset path must point to a directory that will contain a Zarr
2223
group to be created and updated. The slice dataset paths may be provided as Zarr as
@@ -433,6 +434,7 @@ You can disable transaction management by specifying
433434
The `target_dir` setting is mandatory. If it is not specified in the configuration,
434435
it must be passed either as `--target` or `-t` option to the `zappend` command or as
435436
`target_dir` keyword argument when using the `zappend` Python function.
437+
Note, the parent directory of `target_dir` must already exist.
436438

437439
If the target path is given for another filesystem, additional storage options may be
438440
passed using the optional `target_storage_options` setting.

tests/test_api.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ def test_some_slices_local(self):
8585
for slice_dir in slices:
8686
shutil.rmtree(slice_dir, ignore_errors=True)
8787

88+
def test_some_slices_local_output_to_non_existing_dir(self):
89+
target_dir = "non_existent_dir/target.zarr"
90+
slices = [
91+
"slice-1.zarr",
92+
"slice-2.zarr",
93+
"slice-3.zarr",
94+
]
95+
for uri in slices:
96+
make_test_dataset(uri=uri)
97+
with pytest.raises(
98+
FileNotFoundError,
99+
match="\\ATarget parent directory does not exist: .*/non_existent_dir\\Z",
100+
):
101+
zappend(slices, target_dir=target_dir)
102+
88103
def test_some_slices_with_class_slice_source(self):
89104
target_dir = "memory://target.zarr"
90105
slices = [make_test_dataset(index=3 * i) for i in range(3)]

zappend/config/markdown.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def _schema_to_md(
4444
one_of = schema.get("anyOf") or schema.get("oneOf")
4545
if one_of:
4646
if sequence_name:
47-
lines.append(f"The {sequence_name} must be one of the following.")
47+
lines.append(f"The {sequence_name} must be one of the following:")
4848
else:
49-
lines.append("Must be one of the following.")
49+
lines.append("Must be one of the following:")
5050
for sub_schema in one_of:
5151
sub_lines = []
5252
_schema_to_md(sub_schema, path, sub_lines)
@@ -55,11 +55,12 @@ def _schema_to_md(
5555
lines.append(" * " + sub_lines[0])
5656
for sub_line in sub_lines[1:]:
5757
lines.append(" " + sub_line)
58+
lines.append("")
5859

5960
const = schema.get("const", undefined)
6061
if const is not undefined:
6162
value = json.dumps(const)
62-
lines.append(f"Its value must be `{value}`.")
63+
lines.append(f"Its value is `{value}`.")
6364

6465
default = schema.get("default", undefined)
6566
if default is not undefined:

zappend/config/schema.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,15 @@
487487
{"description": "Monotonically increasing.", "const": "+"},
488488
{"description": "Monotonically decreasing.", "const": "-"},
489489
{
490-
"description": "A time delta value.",
490+
"description": (
491+
"A positive or negative time delta value,"
492+
" such as `12h`, `2D`, `-1D`."
493+
),
491494
"type": "string",
492495
"not": {"const": ""},
493496
},
494497
{
495-
"description": "A numerical delta value.",
498+
"description": "A positive or negative numerical delta value.",
496499
"type": "number",
497500
"not": {"const": 0},
498501
},
@@ -520,7 +523,7 @@
520523
target_dir={
521524
"description": (
522525
"The URI or local path of the target Zarr dataset."
523-
" Must be a directory."
526+
" Must specify a directory whose parent directory must exist."
524527
),
525528
"type": "string",
526529
"minLength": 1,

0 commit comments

Comments
 (0)