-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional axes bounds as semi-open interval (#7547)
* WIP: Additional axes bounds as semi-open interval * make upper bound exclusive in more places * WIP: migration script for datasource-properties.jsons * naming in nml * fix mag parsing in zarr volume upload * migration * changelog+migration guide * nml snapshots * Update CHANGELOG.unreleased.md Co-authored-by: frcroth <[email protected]> * implement feedback on python migration --------- Co-authored-by: frcroth <[email protected]>
- Loading branch information
Showing
12 changed files
with
74 additions
and
20 deletions.
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
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
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
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
Binary file modified
BIN
+5 Bytes
(100%)
frontend/javascripts/test/snapshots/public-test/test-bundle/test/libs/nml.spec.js.snap
Binary file not shown.
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,51 @@ | ||
from pathlib import Path | ||
import json | ||
import shutil | ||
import time | ||
import argparse | ||
|
||
# Traverses a binaryData directory and changes all datasource-properties.jsons | ||
# that include additionalAxes, increasing the upper bound by 1 | ||
# This follows a change in the upper bound semantic to be exclusive | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--dry", | ||
action="store_true", | ||
) | ||
parser.add_argument("binary_data_dir", type=Path, help="WEBKNOSSOS binary data dir") | ||
args = parser.parse_args() | ||
dry = args.dry | ||
binary_data_dir = args.binary_data_dir | ||
|
||
count = 0 | ||
print(f"Traversing datasets at {binary_data_dir.resolve()} ...") | ||
for orga_dir in [item for item in binary_data_dir.iterdir() if item.is_dir()]: | ||
for dataset_dir in [item for item in orga_dir.iterdir() if item.is_dir()]: | ||
json_path = dataset_dir / "datasource-properties.json" | ||
if json_path.exists(): | ||
changed = False | ||
with open(json_path, 'r') as json_file: | ||
content = json.load(json_file) | ||
for layer in content.get("dataLayers", []): | ||
for axis in layer.get("additionalAxes", []): | ||
if "bounds" in axis: | ||
bounds = axis["bounds"] | ||
if len(bounds) >= 2: | ||
bounds[1] = bounds[1] + 1 | ||
changed = True | ||
if changed: | ||
print(f"Updating {json_path} (dry={dry})...") | ||
count += 1 | ||
backup_path = Path(f"{json_path}.{round(time.time() * 1000)}.bak") | ||
|
||
if not dry: | ||
shutil.copyfile(json_path, backup_path) | ||
with open(json_path, 'w') as json_outfile: | ||
json.dump(content, json_outfile, indent=4) | ||
|
||
print(f"Updated {count} datasets (dry={dry})") | ||
|
||
if __name__ == '__main__': | ||
main() |
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