dd_scenario.Container¶
-
class
dd_scenario.Container(parent_id=None, json=None, pc=None, **kwargs)¶ The container class.
-
__init__(parent_id=None, json=None, pc=None, **kwargs)¶ Creates a new container.
Examples
Creates a list of
Containerfrom containers metadata of a project, for instance, the response.json() fromget_containers():>>> containers = [Container(json=s) for s in client.get_containers()]
Creates a container with a given name and projectId:
>>> container = Container(name="foo", projectId="aeiou")
Creates a container with a given name and using the project context:
>>> container = Container(name="foo", pc=pc)
Parameters: - json (
dict, optional) – The dict describing the container. - pc (
projectContext, optional) – The project context - **kwargs (optional) – kwargs to override container attributes.
Attributes specified here will override those of
desc.
- json (
-
add_asset_data(name, data=None)¶ Adds or updates asset data.
Parameters: - name – The name of the asset
- data – A stream containing the data to upload.
Returns: the asset metadata as
Asset
-
add_table_data(what, data=None, category=None)¶ Adds the table data to the container.
Data must be
pandas.DataFrame.Examples
Adds the data for the table with the specified name:
>>> container.add_table_data("table1", data=table1_data)
Adds the data for the tables in the dict:
>>> tables = { "table1": table1_df, "table2": table2_df } >>> scenario.add_table_data(tables)
Parameters: - what – what to add. Can be either a table name or a dict of
{table_name: table_data} - data – The data if
whatis a table name.
- what – what to add. Can be either a table name or a dict of
-
copy(name)¶ Copies this container.
- Arg:
- name (Mandatory): The name of the copy.
Returns: The Containerfor the copy.
-
create_asset(name, data=None, category='model')¶ Creates an asset.
-
delete_asset(name)¶ Deletes the asset.
Parameters: name – The name of the asset as a string.
-
delete_table_data(table)¶ Calls
self.client.delete_table_data(self, table)See
dd_sccontainerlient.delete_table_data().
-
get_asset(name)¶ Gets asset metadata using name.
Parameters: - asset – An asset or asset name as a string.
- name – An asset name.
Returns: A
Assetinstance.
-
get_asset_data(name)¶ Gets asset data.
Parameters: name – The name of the asset. Returns: The asset data as a byte array.
-
get_assets()¶ Returns asset metadata for all of this container’s assets.
Returns: A dict where its keys are asset names and its values are Asset’s metadata.
-
get_table_data(table)¶ Calls
self.client.get_table_data(self, table)
-
get_table_type(name)¶ Returns a
TableType`descriptor for thetablewhich name is specified.See
dd_scenario.Client.get_table_type().Parameters: name – A table name as a string. Returns: A TableTypeinstance.
-
get_tables(category=None)¶ Returns all container table metadata.
Parameters: category – The category of tables. Can be ‘input’, ‘output’ or None if both input and output tables are to be returned. Returns: A dict where its keys are asset names and its values are Table.
-
get_tables_data(category=None)¶ Returns a dict of all tables. Keys are table names, values are DataFrames with table data.
-
solve(display_log=None, log_lines=25, log_output=None, **kwargs)¶ Solves this scenario.
If an error occurs and
display_logis None or not set, this prints the lastlog_lineslines of log (default: 25)If
display_logis set to False, nothing is displayed.If display_log is set to True, the log are always displayed.
Parameters: - **kwargs – extra arguments passed as SolveConfig attributes
- display_log – If True, log is downloaded after solve and displayed. Default is False
- log_lines – number of lines of log to print. Default is 25. If None, all log lines are displayed.
- log_output – the file like object to write logs to. If not specified or None, defaults to sys.stdout.
-
update_table_type(table_type)¶ Updates the table type for the specified table type.
Calls
self.client.update_table_type(self, table_type.id, new_value=table_type)See
dd_scenario.Client.update_table_type().Parameters: table_type – A TableType for the update.
-