decision_optimization_client.Container
- class decision_optimization_client.Container
- name
Name of the container
- description
Description of the container
- category
Category of the container, can be
scenario
ordashboard
- lineage
If the container has been copied, name of the container that it was copied from
- projectId
ID of the project the container is a part of
- add_asset_data(name, data=None, category='model')
Adds or updates asset data.
- Parameters
name – The name of the asset
data – A stream containing the data to upload.
category – The category (defaults to
model
)
- 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
what
is a table name.
- copy(name)
Copies this container.
- Arg:
name (Mandatory): The name of the copy.
- Returns
The
Container
for the copy.
- delete_asset(name)
Deletes the asset.
- Parameters
name – The name of the asset as a string.
- delete_table_data(table)
Deletes table data.
- Parameters
table –
Table
from which you want the data to be deleted
- export_asset(asset_name, project_asset_name=None, project_asset_id=None)
Exports scenario asset into a project data asset.
- Parameters
asset_name – The name of the asset in the scenario.
project_asset_name – The name of a new data asset to be created in the project
project_asset_id – The ID of an existing data asset in the project to be overwritten
Only one of
project_asset_name
orproject_asset_id
parameters can be used. If none is provided a new asset is created using the source asset name.- Returns
An ID of the resulting project asset
- export_table(table_name, project_asset_name=None, project_asset_id=None, write_mode=None)
Exports a scenario table into a project data asset.
- Parameters
table_name – The name of the table in the scenario
project_asset_name – The name of a new data asset to be created in the project
project_asset_id – The ID of an existing data asset in the project to be overwritten
write_mode – The write mode:
append
ortruncate
. Useful for connected data. Ignored for project assets that do not support it
Only one of
project_asset_name
orproject_asset_id
parameters can be used. If none is provided a new asset is created using the source table name with .csv extension.- Returns
An ID of the resulting project asset
- get_asset(name)
Gets asset metadata using name.
- Parameters
name – An asset name.
- Returns
A
Asset
instance.
- 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_status()
Get the solve status for this scenario
- Returns
A JSON describing the solve status for that scenario
- get_table_data(table)
Gets table data.
- Parameters
table –
Table
from which you want the data- Returns
A
pandas.DataFrame
containing the data.
- get_table_type(name)
Returns a
TableType
descriptor for theTable
which name is specified.- Parameters
name – A table name as a string.
- Returns
A
TableType
instance.
- get_tables(category=None)
Returns all container table metadata.
- Parameters
category – The category of tables. Can be
input
,output
orNone
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)
- Parameters
category – The category of tables. Can be
input
,output
orNone
if both input and output tables are to be returned.- Returns
A dict of all tables. Keys are table names, values are DataFrames with table data.
- import_asset(project_asset_id, imported_asset_name, category='input', lineage=None)
Imports asset from the project.
- Parameters
project_asset_id – The ID of the project data asset to be imported
imported_asset_name – The name of the new asset in the scenario
category – The category for the asset. Default:
input
lineage – Optional comment about the asset lineage
- import_table(project_asset_id, imported_table_name, category='input', lineage=None)
Imports table from a project data asset.
- Parameters
project_asset_id – The ID of the project data asset to be imported
imported_table_name – The name of the new table in the scenario
category – The category for the table. Default:
input
lineage – Optional comment about the table lineage
- solve(display_log=None, log_lines=25, log_output=None, asynchronous=False, timeout=None, environment_id=None, **kwargs)
Solves this scenario.
If an error occurs and
display_log
is None or not set, this prints the lastlog_lines
lines of log (default: 25)If
display_log
is set to False, nothing is displayed.If
display_log
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.
asynchronous – If true, the solve will be done asynchronously (it won’t wait for it to finish), allowing you to do multiple solves in parallel
environment_id – Environment to use to solve this scenario. Useful to override the default environment selected at Decision Optimization Experiment level
- Returns
A JSON describing the status of the job that has been launched for this container.