File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 33import os
44import tarfile
55import tempfile
6+ import time
67from typing import Optional
78
89
910from ... import Openlayer
1011from . import StorageType , _upload
12+ from ...types .commit_retrieve_response import CommitRetrieveResponse
1113
1214
1315def push (
@@ -46,3 +48,30 @@ def push(
4648 commit = {"message" : message , "source" : "cli" },
4749 storage_uri = presigned_url_response .storage_uri ,
4850 )
51+
52+
53+ def wait_for_commit_completion (
54+ client : Openlayer , project_version_id : str , verbose : bool = True
55+ ) -> CommitRetrieveResponse :
56+ """Wait for a commit to be processed by the Openlayer platform.
57+
58+ Waits until the commit status is "completed" or "failed".
59+ """
60+ while True :
61+ commit = client .commits .retrieve (project_version_id = project_version_id )
62+ if commit .status == "completed" :
63+ if verbose :
64+ print (f"Commit { project_version_id } completed successfully." )
65+ return commit
66+ elif commit .status == "failed" :
67+ raise Exception (
68+ f"Commit { project_version_id } failed with status message:"
69+ f" { commit .status_message } "
70+ )
71+ else :
72+ if verbose :
73+ print (
74+ f"Commit { project_version_id } is still processing (status:"
75+ f" { commit .status } )..."
76+ )
77+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments