From 595705dc50a9b9364d31a3d8f98fba18cf800675 Mon Sep 17 00:00:00 2001 From: Marc Julien Date: Mon, 18 Nov 2024 13:44:28 -0800 Subject: [PATCH] python(feat):Add ch10 upload service --- python/examples/data_import/ch10/main.py | 51 +++++++++++++++++++ .../data_import/ch10/requirements.txt | 2 + python/lib/sift_py/data_import/ch10.py | 2 +- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 python/examples/data_import/ch10/main.py create mode 100644 python/examples/data_import/ch10/requirements.txt diff --git a/python/examples/data_import/ch10/main.py b/python/examples/data_import/ch10/main.py new file mode 100644 index 00000000..d7ad145e --- /dev/null +++ b/python/examples/data_import/ch10/main.py @@ -0,0 +1,51 @@ +""" +Example ch10 upload. + +This example will not work out of the box. Replace ExampleCh10File with +an implementation of the class that can parse your ch10 files. +""" + +import os + +from dotenv import load_dotenv +from sift_py.data_import.ch10 import BaseCh10File, Ch10UploadService +from sift_py.data_import.status import DataImportService +from sift_py.rest import SiftRestConfig + + +class ExampleCh10File(BaseCh10File): + pass + + +if __name__ == "__main__": + """ + Example of uploading a TDMS file into Sift. + """ + load_dotenv() + + sift_uri = os.getenv("SIFT_API_URI") + assert sift_uri, "expected 'SIFT_API_URI' environment variable to be set" + + apikey = os.getenv("SIFT_API_KEY") + assert apikey, "expected 'SIFT_API_KEY' environment variable to be set" + + asset_name = os.getenv("ASSET_NAME") + assert asset_name, "expected 'ASSET_NAME' environment variable to be set" + + rest_config: SiftRestConfig = { + "uri": sift_uri, + "apikey": apikey, + } + + ch10_file = ExampleCh10File("sample_data.ch10") + ch10_upload_service = Ch10UploadService(rest_config) + + import_service: DataImportService = ch10_upload_service.upload( + ch10_file, + asset_name, + ) + print(import_service.get_data_import()) + + print("Waiting for upload to complete...") + import_service.wait_until_complete() + print("Upload example complete!") diff --git a/python/examples/data_import/ch10/requirements.txt b/python/examples/data_import/ch10/requirements.txt new file mode 100644 index 00000000..2dda90fe --- /dev/null +++ b/python/examples/data_import/ch10/requirements.txt @@ -0,0 +1,2 @@ +python-dotenv +sift-stack-py diff --git a/python/lib/sift_py/data_import/ch10.py b/python/lib/sift_py/data_import/ch10.py index 9509197c..b554a284 100644 --- a/python/lib/sift_py/data_import/ch10.py +++ b/python/lib/sift_py/data_import/ch10.py @@ -32,7 +32,7 @@ def __next__(self): class Ch10UploadService(CsvUploadService): """Service to upload ch10 files.""" - def upload( + def upload_ch10( self, ch10_file: BaseCh10File, asset_name: str,