Skip to content

Commit c6fd351

Browse files
authored
Use project dir end point (#466)
1 parent 0bc1a70 commit c6fd351

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ansys/hps/client/jms/api/jms_api.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import logging
2828
import os
2929
from typing import Dict, List, Union
30-
import uuid
3130

3231
import backoff
3332

@@ -409,10 +408,16 @@ def _restore_project(jms_api, archive_path):
409408
if not os.path.exists(archive_path):
410409
raise HPSError(f"Project archive: path does not exist {archive_path}")
411410

412-
bucket = f"hps-client-restore-{uuid.uuid4()}"
413-
414411
log.info(f"Uploading archive {archive_path}")
415412

413+
# POST project archive dir creation request
414+
url = f"{jms_api.url}/projects/dir"
415+
r = jms_api.client.session.post(url)
416+
if not r.json()["project_dir"]:
417+
msg = "Failed to create the archive restore dir."
418+
msg += f" Request response: {r.json()}"
419+
raise HPSError(f"{msg}")
420+
bucket = r.json()["project_dir"][0]
416421
_upload_archive(jms_api, archive_path, bucket)
417422

418423
# POST restore request

0 commit comments

Comments
 (0)