@@ -119,6 +119,20 @@ def sleep_until_complete(self, verbose_std_out=True):
119119 if final_status ["status" ] == "Errored" :
120120 raise JobError (final_status , self )
121121
122+ @classmethod
123+ def from_id (cls , job_id : str , client : "NucleusClient" ): # type: ignore # noqa: F821
124+ """Creates a job instance from a specific job Id.
125+
126+ Parameters:
127+ job_id: Defines the job Id
128+ client: The client to use for the request.
129+
130+ Returns:
131+ The specific AsyncMethod (or inherited) instance.
132+ """
133+ job = client .get_job (job_id )
134+ return cls .from_json (job .__dict__ , client )
135+
122136 @classmethod
123137 def from_json (cls , payload : dict , client ):
124138 # TODO: make private
@@ -131,6 +145,34 @@ def from_json(cls, payload: dict, client):
131145 )
132146
133147
148+ class EmbeddingsExportJob (AsyncJob ):
149+ def result_urls (self , wait_for_completion = True ) -> List [str ]:
150+ """Gets a list of signed Scale URLs for each embedding batch.
151+
152+ Parameters:
153+ wait_for_completion: Defines whether the call shall wait for
154+ the job to complete. Defaults to True
155+
156+ Returns:
157+ A list of signed Scale URLs which contain batches of embeddings.
158+
159+ The files contain a JSON array of embedding records with the following schema:
160+ [{
161+ "reference_id": str,
162+ "embedding_vector": List[float]
163+ }]
164+ """
165+ if wait_for_completion :
166+ self .sleep_until_complete (verbose_std_out = False )
167+
168+ status = self .status ()
169+
170+ if status ["status" ] != "Completed" :
171+ raise JobError (status , self )
172+
173+ return status ["message" ]["result" ] # type: ignore
174+
175+
134176class JobError (Exception ):
135177 def __init__ (self , job_status : Dict [str , str ], job : AsyncJob ):
136178 final_status_message = job_status ["message" ]
0 commit comments