Skip to content

Commit

Permalink
Merge branch 'feature/json-archive' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gmertes committed May 8, 2024
2 parents 1e64fa5 + 69590dd commit 8cac362
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/ai_models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,34 @@ def collect_archive_requests(self, written):
def finalise(self):
if self.archive_requests:
with open(self.archive_requests, "w") as f:
json_requests = []

for path, archive in self.archiving.items():
request = dict(source=f'"{path}"', expect=archive.expect)
request.update(archive.request)
request.update(self._requests_extra)
self._print_request("archive", request, file=f)

if self.json:
json_requests.append(request)
else:
self._print_request("archive", request, file=f)

if json_requests:

def json_default(obj):
if isinstance(obj, set):
if len(obj) > 1:
return list(obj)
else:
return obj.pop()
return obj

print(
json.dumps(
json_requests, separators=(",", ":"), default=json_default
),
file=f,
)

def download_assets(self, **kwargs):
for file in self.download_files:
Expand Down

0 comments on commit 8cac362

Please sign in to comment.