SDK API Reference¶
halsted_sdk.client.HalstedClient
¶
A client for the Halsted SDK.
process_video(filepath)
¶
Process a surgical video and return the predictions as a dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
The local path to the video to process. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
A dataframe of the predictions. |
halsted_sdk.upload.VideoUploader
¶
A class to upload a video to the cloud storage.
complete_multipart_upload(inputs)
¶
Complete a multipart upload to the cloud storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict
|
A dictionary containing the upload ID and the parts. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
status_code |
int
|
The status code of the response. |
create_multipart_upload()
¶
Create a multipart upload to the cloud storage.
Returns:
| Name | Type | Description |
|---|---|---|
upload_id |
str
|
The upload ID. |
upload(local_file_path)
¶
Upload local video file to S3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_file_path
|
str
|
Path to the local video file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
status_code |
int
|
The status code of the response. |
upload_part(inputs)
¶
Upload a part of the video to the cloud storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict
|
A dictionary containing the part number, the upload ID, and the chunk. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
etag |
str
|
The ETag of the uploaded part. |
halsted_sdk.process.VideoProcessor
¶
A class to process a surgical video.
process(video_path)
¶
Process a video and return the predictions as a dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
str
|
The local path to the video to process. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
A dataframe of the predictions. |
process_multiple_videos(inputs)
¶
Process multiple videos and return the predictions as a dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
list[dict]
|
The list of inputs to process. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
A dataframe of the predictions. |
halsted_sdk.sagemaker.SagemakerEndpoint
¶
A class to invoke the sagemaker endpoint.
get_inputs(video_id, df)
¶
Get the processing inputs for the sagemaker endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The dataframe containing the processing inputs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
processing_inputs |
list[dict]
|
The list of processing inputs. |
invoke(extra_inputs=None)
¶
Invoke the sagemaker endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extra_inputs
|
dict
|
A dictionary containing the extra inputs. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
response |
dict
|
indicating status code and the response body of the request. |
halsted_sdk.process.S3Operator
¶
A class to interact with the S3 bucket.
check_inference_status(path_to_s3_results, path_to_s3_failure, wait_time=10, timeout=3600)
¶
Check the status of the inference process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_s3_results
|
str
|
The path to the S3 bucket where the results of the inference are stored. |
required |
path_to_s3_failure
|
str
|
The path to the S3 bucket where the failure of the inference is stored. |
required |
wait_time
|
int
|
The time to wait between polling the S3 bucket. |
10
|
timeout
|
int
|
The maximum time to wait for the inference to complete. |
3600
|
Returns:
| Type | Description |
|---|---|
dict
|
dict The status of the inference. |
get_content_from_endpoint(response)
¶
Get the content from the endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
dict
|
The response from the endpoint. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
The dataframe of the content. |
get_file_from_s3(path_to_s3_uri)
¶
Gets a file from S3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_s3_uri
|
str
|
The path to the S3 file to get. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
content |
str
|
The content of the file. |
list_objects(path_to_s3_uri)
¶
List objects in an S3 bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_s3_uri
|
str
|
The path to the S3 bucket to list objects from. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
response |
dict
|
The response from the request indicating the availability of the objects. |
upload_json_to_s3(extra_inputs)
¶
Uploads a dictionary to an S3 bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extra_inputs
|
dict
|
The dictionary containing the extra inputs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
status_code |
int
|
The status code of the response. |