When you submit a job you can include inline data, or reference your data in your request. This data is then mapped to a file named with data identifier and used by the model. The data identifier extension defines the format of the file used. You can define what input data you want to use and how you collect it (as either inline or referenced data).
Inline data
You can embed inline data in your request.
- Tabular inline data
- This example generates the corresponding
file that is used as the model input file. Onlydiet_food.csv
files are supported.csv
"input_data": [{ "id":"diet_food.csv", "fields" : ["name","unit_cost","qmin","qmax"], "values" : [ ["Roasted Chicken", 0.84, 0, 10] ] }]
- Raw inline data
- This type of inline data is useful for files such as an OPL
file or an.dat
file..lp
"input_data": [{ "id":"model.lp", "content":"<model encoded as base64 string>" }]
Referenced data
When using data or connection assets for tabular data, use
as the data-identifier extension in the .csv
field, regardless
of the asset type. The data-connector makes the necessary transformations, so that you can load data
without needing to change the format of the data. You can thus use the same Decision
Optimization model with many different data-source types and formats by using a
data-connector to reference your data. If you use other data-identifier extensions, the data is
loaded as a raw-data binary-file without any transformation. id
- Data assets
- You can use data asset references to locate any data asset present in your space and benefit
from the data-connector integration capabilities. To use data assets from a project, you must first
promote them to your space.
This example defines input data references to a data asset in a space.
"input_data_references": [{ "type": "data_asset", "id": "diet_food.csv", "connection": {}, "location": { "href": "/v2/assets/<ASSET_ID>?space_id=<SPACE_ID>" } }]
This example shows you how to load a Microsoft Excel file asset <ASSET_ID> from space <SPACE_ID>.
"input_data_references": [{ "type": "data_asset", "id": "kpis.csv", "connection": {}, "location": { "href": "/v2/assets/<ASSET_ID>?space_id=<SPACE_ID>" } }]
- Connection assets
- You can use connection assets to reference any data and then refer to the connection without
having to specify credentials each time. Referencing a secure connection without having to use
inline credentials in the payload also offers you better security. You can use the
to identify connections. For example,id
"input_data_references": [{ "type": "connection_asset", "id": "diet_food.csv", "connection": { "id" : "<CONNECTION_ID>", } "location": { <Data-connector interaction properties depending on connection type> } }]
The
is the globally unique identifier for a connection. You can find this identifier when you have created a connection and you then edit the connection in your project. The identifier is visible in the Edit connection window's URL.<CONNECTION_ID>
For information about job definitions, see Deployment job definitions.
You can specify the interaction properties that are required for the connection in the
field.location
This example connects to a COS/S3 bucket. The interaction properties are provided in the
field.location
"location": { "file_name" : "<FILENAME>", "bucket" : "<BUCKET_NAME>" }
This example connects to a Db2 asset. The interaction properties are provided in the
field.location
"location" : { "table_name" : "<TABLE_NAME>", "schema_name" : "<SCHEMA_NAME>" }
This example connects to a COS/S3 bucket. The connection reference is provided in the
field.id
"input_data_references": [{ "type": "connection_asset", "id": "diet_food.csv", "connection": { "id" : "<CONNECTION_ID>" }, "location": { "file_name" : "<FILENAME>", "bucket" : "<BUCKET_NAME>" } }]
This example shows you how to load a Microsoft Excel file from a COS/S3 bucket."input_data_references": [{ "type": "kpis.csv", "id": "diet_food.csv", "connection": { "id" : "<CONNECTION_ID>" }, "location": { "file_name" : "<kpis.xlsx>", "bucket" : "<BUCKET_NAME>" } }]
This example shows you how to connect to a Db2 asset. The connection reference is provided in the
field.id
"input_data_references": [{ "type" : "connection_asset", "id" : "diet_food.csv", "connection" : { "id" : "<CONNECTION_ID>" }, "location" : { "table_name" : "<TABLE_NAME>", "schema_name" : "<SCHEMA_NAME>" } }]
For more information about the interaction properties that you can use in the
field, see Platform connections in the main menu. On the Connections page, select Connection resources > Connection properties. Then select the Interaction properties > As a source tab for the relevant connector. You might need to create a Platform assets catalog.location
For more information about the different connections available for Decision Optimization, see Supported data sources in Decision Optimization.
- URL referenced data
- You can use URL-referenced data to load data from a particular URL.This example uses the
command to retrieve theGET
file from a URL as input data for the Decision Optimization deployment job.diet_food.csv
"input_data_references": { "type": "url", "id": "diet_food.csv", "connection": { "verb": "GET", "url": "https://myserver.com/diet_food.csv", "headers": { "Content-Type": "application/x-www-form-urlencoded" } }, "location": {} }
You can combine different types of data in the same request. For more information about data definitions, see Adding data to an analytics project.