Skip to content

Commit

Permalink
Consistent Checkpoint ID
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Feb 27, 2024
1 parent d27e583 commit 9a95949
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion services/gpu/lib/ModelSrv.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def load_timeframe(self, body, websocket):
)

self.timeframe = TimeFrame.load(self.api, body["id"])
self.meta_load_checkpoint(self.timeframe.checkpointid)
self.meta_load_checkpoint(self.timeframe.checkpoint_id)

websocket.send(
json.dumps(
Expand Down
2 changes: 1 addition & 1 deletion services/gpu/lib/TimeFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, api, aoi, tf, is_patch=False):
self.name = aoi.get("name", "Default Name")

# TimeFrame Properties
self.checkpointid = tf["checkpoint_id"]
self.checkpoint_id = tf["checkpoint_id"]
self.mosaic = tf["mosaic"]
self.is_patch = is_patch
self.tiles = []
Expand Down
24 changes: 12 additions & 12 deletions services/gpu/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ def create_checkpoint(

return body

def get_checkpoint(self, checkpointid):
def get_checkpoint(self, checkpoint_id):
url = (
self.url
+ "/api/project/"
+ str(self.project_id)
+ "/checkpoint/"
+ str(checkpointid)
+ str(checkpoint_id)
)
LOGGER.info("ok - GET " + url)
r = self.requests.get(url, headers={"authorization": "Bearer " + self.token})
Expand All @@ -160,21 +160,21 @@ def get_checkpoint(self, checkpointid):

return body

def upload_checkpoint(self, checkpointid):
def upload_checkpoint(self, checkpoint_id):
url = (
self.url
+ "/api/project/"
+ str(self.project_id)
+ "/checkpoint/"
+ str(checkpointid)
+ str(checkpoint_id)
+ "/upload"
)

LOGGER.info("ok - POST " + url)

ch_dir = self.tmp_checkpoints + "/" + str(checkpointid)
ch_dir = self.tmp_checkpoints + "/" + str(checkpoint_id)

zip_fs = self.tmp_dir + "/checkpoints/checkpoint-{}.zip".format(checkpointid)
zip_fs = self.tmp_dir + "/checkpoints/checkpoint-{}.zip".format(checkpoint_id)

zipf = zipfile.ZipFile(zip_fs, "w", zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk(ch_dir):
Expand Down Expand Up @@ -205,19 +205,19 @@ def upload_checkpoint(self, checkpointid):
LOGGER.info("ok - Received " + url)
return r.json()

def download_checkpoint(self, checkpointid):
def download_checkpoint(self, checkpoint_id):
url = (
self.url
+ "/api/project/"
+ str(self.project_id)
+ "/checkpoint/"
+ str(checkpointid)
+ str(checkpoint_id)
+ "/download"
)

LOGGER.info("ok - GET " + url)

ch_dir = self.tmp_checkpoints + "/" + str(checkpointid)
ch_dir = self.tmp_checkpoints + "/" + str(checkpoint_id)

r = self.requests.get(
url,
Expand All @@ -228,15 +228,15 @@ def download_checkpoint(self, checkpointid):

r.raise_for_status()

ch_zip_fs = self.tmp_dir + "/checkpoint-{}.zip".format(checkpointid)
ch_zip_fs = self.tmp_dir + "/checkpoint-{}.zip".format(checkpoint_id)
with open(ch_zip_fs, "wb") as f:
for chunk in r.iter_content(chunk_size=10240):
if chunk:
f.write(chunk)

LOGGER.info("ok - Received " + url)

ch_dir = self.tmp_checkpoints + "/" + str(checkpointid)
ch_dir = self.tmp_checkpoints + "/" + str(checkpoint_id)
os.makedirs(ch_dir, exist_ok=True)

with zipfile.ZipFile(ch_zip_fs, "r") as zip_ref:
Expand Down Expand Up @@ -373,7 +373,7 @@ def create_timeframe(self, timeframe):
"content-type": "application/json",
},
data=json.dumps(
{"checkpoint_id": timeframe.checkpointid, "mosaic": timeframe.mosaic}
{"checkpoint_id": timeframe.checkpoint_id, "mosaic": timeframe.mosaic}
),
)

Expand Down

0 comments on commit 9a95949

Please sign in to comment.