Skip to content

Commit

Permalink
using new ZenodoMeteDataClass
Browse files Browse the repository at this point in the history
  • Loading branch information
drifter089 committed Nov 28, 2024
1 parent 67fcd0e commit ca75a86
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/version_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
python-version: 3.12

- name: install req
run: pip install git+https://github.com/drifter089/zenodopy.git@basic_test#egg=zenodopy
run: pip install git+https://github.com/drifter089/zenodopy.git@new_metadata_class#egg=zenodopy

- name: Update Zenodo Deposition
run: |
Expand Down
3 changes: 2 additions & 1 deletion src/zenodopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
Set up module access for the base package
"""
from .zenodopy import Client
from .zenodopy import ZenodoMetadata

__all__ = ['Client']
__all__ = ['Client','ZenodoMetadata']
25 changes: 8 additions & 17 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from pathlib import Path
import argparse
import zenodopy
from zenodopy import ZenodoMetadata
import parse

def parse_metadata_from_json(json_file_path: Path) -> zenodopy.ZenodoMetadata:
"""Parse metadata from a JSON file into a ZenodoMetadata object."""
Expand All @@ -19,7 +17,8 @@ def parse_metadata_from_json(json_file_path: Path) -> zenodopy.ZenodoMetadata:
data = json.load(json_file)

metadata_dict = data.get("metadata", {})
return ZenodoMetadata(**metadata_dict)
return zenodopy.ZenodoMetadata(**metadata_dict)


def main():
# Set up argument parsing
Expand All @@ -41,19 +40,11 @@ def main():
upload_dir = Path(args.upload_dir)

print("Version Tag:", version_tag)

def prepare_metadata(file_path, new_version):
with open(file_path, "r") as file:
zenodo_data = json.load(file)

zenodo_data["metadata"]["version"] = new_version

with open(file_path, "w") as file:
json.dump(zenodo_data, file, indent=2)

# Prepare the metadata file with the new version tag
prepare_metadata(zenodo_metadata_file, version_tag)


# Parse and update metadata with new version tag
metadata = parse_metadata_from_json(zenodo_metadata_file)
metadata.version = version_tag

max_retries = 5

for attempt in range(1, max_retries + 1):
Expand All @@ -68,7 +59,7 @@ def prepare_metadata(file_path, new_version):
zeno.update(
source=str(upload_dir),
publish=True,
metadata_json=str(zenodo_metadata_file),
metadata_json=metadata,
)
print("Update succeeded.")
break
Expand Down

0 comments on commit ca75a86

Please sign in to comment.