Skip to content

Commit

Permalink
python(feat):Add ch10 upload service
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsiftstack committed Nov 18, 2024
1 parent cbd9704 commit 595705d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
51 changes: 51 additions & 0 deletions python/examples/data_import/ch10/main.py
Original file line number Diff line number Diff line change
@@ -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!")
2 changes: 2 additions & 0 deletions python/examples/data_import/ch10/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python-dotenv
sift-stack-py
2 changes: 1 addition & 1 deletion python/lib/sift_py/data_import/ch10.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 595705d

Please sign in to comment.