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 3
3
import os
4
4
import tarfile
5
5
import tempfile
6
+ import time
6
7
from typing import Optional
7
8
8
9
9
10
from ... import Openlayer
10
11
from . import StorageType , _upload
12
+ from ...types .commit_retrieve_response import CommitRetrieveResponse
11
13
12
14
13
15
def push (
@@ -46,3 +48,30 @@ def push(
46
48
commit = {"message" : message , "source" : "cli" },
47
49
storage_uri = presigned_url_response .storage_uri ,
48
50
)
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