Transaction
Module superwise.controller.transaction
This module implement data functionality
Classes
TransactionController(client, sw, internal_bucket)
Transaction Controller is in-charge for create transaction using file or batch request
Args:
client
: superwise client object
sw
: superwise object
Ancestors (in MRO)
- superwise.controller.base.BaseController
- abc.ABC
Methods
get(self, transaction_id: str)
Description:
Get transaction by transaction id
Args:
transaction_id
: string - transaction_id to fetch from server
Return:
Transaction object
log_file(self, file_path: str, version_id: Optional[str] = None, model_id: Optional[str] = None, metadata: Optional[dict] = None)
Description:
Stream data of a given file path
Args:
file_path
: url for file stored in cloud str
transaction_id
: string - uuid of the log operation
version_id
: string - id of version (optional)
model_id
: string - id of model (optional)
metadata
: dict - dict of metadata of transaction
Return:
json object represent the transaction from server
log_from_azure(self, azure_uri: str, connection_string: str, version_id: Optional[str] = None, model_id: Optional[str] = None, metadata: Optional[dict] = None)
Description:
Upload file from Azure Blob Storage to superwise bucket
Args:
azure_uri
: URI of file (URI scheme is the Azure Blob Filesystem driver: abfs://my_container/path/to/blob)
connection_string
: Azure Storage connection string
version_id
: string - id of version (optional)
model_id
: string - id of model (optional)
metadata
: dict - dict of metadata of transaction
log_from_dataframe(self, dataframe: pandas.core.frame.DataFrame, version_id: Optional[str] = None, model_id: Optional[str] = None, metadata: Optional[dict] = None)
Description:
Upload file from in memory dataframe to superwise bucket
Args:
dataframe
: pd.DataFrame - dataframe with data to log
version_id
: string - id of version (optional)
model_id
: string - id of model (optional)
metadata
: dict - dict of metadata of transaction
log_from_gcs(self, file_path: str, service_account: Optional[Dict[~KT, ~VT]] = None, version_id: Optional[str] = None, model_id: Optional[str] = None, metadata: Optional[dict] = None)
Description:
Upload file from gcs bucket to superwise bucket
Args:
file_path
: gcs file path
service_account
: dict of the json service account,
alternatively you can set GOOGLE_APPLICATION_CREDENTIALS env var
transaction_id
: string - uuid of the log operation
version_id
: string - id of version (optional)
model_id
: string - id of model (optional)
metadata
: dict - dict of metadata of transaction
log_from_local_file(self, file_path: str, version_id: Optional[str] = None, model_id: Optional[str] = None, metadata: Optional[dict] = None)
Description:
Upload file from local machine to superwise bucket
Args:
file_path
: Local path to file
version_id
: string - id of version (optional)
model_id
: string - id of model (optional)
metadata
: dict - dict of metadata of transaction
log_from_s3(self, file_path: str, aws_access_key_id: Optional[str] = None, aws_secret_access_key: Optional[str] = None, role_arn: Optional[str] = None, version_id: Optional[int] = None, model_id: Optional[int] = None, metadata: Optional[dict] = None)
Description:
Upload file from s3 bucket to superwise bucket. The permission for the client s3 bucket should be by providing aws_access_key_id and aws_secret_access_key or
Args:
file_path
: s3 url path
aws_access_key_id
:
aws_secret_access_key
: .
role_arn
: AWS Role arn
version_id
: string - id of version (optional)
model_id
: string - id of model (optional)
log_records(self, model_id: str, records: List[dict], version_id: Union[str, int, None] = None, metadata: Optional[Dict[~KT, ~VT]] = None)
Description:
Send list of records
Args:
model_id
: string - model id
version_id
: int - version id of the model - Optional[for prediction records]
records
: List[dict] - list of records of data, each record is a dict.
transaction_id
: string - uuid of the log operation
metadata
: dict - dict of metadata of transaction