# Adding data assets to a deployment space #

Learn about various ways of adding and promoting data assets to a space and data types that are used in deployments\.

Data can be:

<!-- <ul> -->

 *  A data file such as a \.csv file
 *  A connection to data that is located in a repository such as a database\.
 *  Connected data that is located in a storage bucket\. For more information, see [Using data from the Cloud Object Storage service](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-space-add-assets.html?context=cdpaas&locale=en#cos-data)\.

<!-- </ul> -->

**Notes:**

<!-- <ul> -->

 *  For definitions of data\-related terms, refer to [Asset types and properties](https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/assets.html)\.

<!-- </ul> -->

You can add data to a space in one of these ways:

<!-- <ul> -->

 *  [Add data and connections to space by using UI](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-space-add-assets.html?context=cdpaas&locale=en#add-directly)
 *  [Promote a data source, such as a file or a connection from an associated project](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-space-promote-assets.html)
 *  [Save a data asset to a space programmatically](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-space-add-assets.html?context=cdpaas&locale=en#add-programmatically)
 *  [Import a space or a project, including data assets, into an existing space](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-space-import-to-space.html)\.

<!-- </ul> -->

Data added to a space is managed in a similar way to data added to a Watson Studio project\. For example:

<!-- <ul> -->

 *  Adding data to a space creates a new copy of the asset and its attachments within the space, maintaining a reference back to the project asset\. If an asset such as a data connection requires access credentials, they persist and are the same whether you are accessing the data from a project or from a space\.
 *  Just like with data connection in a project, you can edit data connection details from the space\.
 *  Data assets are stored in a space in the same way that they are stored in a project\. They use the same file structure for the space as the structure used for the project\.

<!-- </ul> -->

## Adding data and connections to space by using UI ##

To add data or connections to space by using UI:

<!-- <ol> -->

1.  From the **Assets** tab of your deployment space, click **Import assets**\.
2.  Choose between adding a connected data asset, local file, or connection to a data source:
    
    <!-- <ul> -->
    
     *  If you want to add a connected data asset, select **Connected data**. Choose a connection and click **Import**.
     *  If you want to add a local file, select **Local file > Data asset**. Upload your file and click **Done**.
     *  If you want to add a connection to a data source, select **Data access > Connection**. Choose a connection and click **Import**.
    
    <!-- </ul> -->
    
<!-- </ol> -->

The data asset displays in the space and is available for use as an input data source in a deployment job\.

Note:Some types of connections allow for using your personal platform credentials\. If you add a connection or connected data that uses your personal platform credentials, tick the **Use my platform login credentials** checkbox\.

## Adding data to space programmatically ##

If you are using APIs to create, update, or delete Watson Machine Learning assets, make sure that you are using only Watson Machine Learning [API calls](https://cloud.ibm.com/apidocs/machine-learning)\.

For an example of how to add assets programmatically, refer to this sample notebook: [Use SPSS and batch deployment with Db2 to predict customer churn](https://github.com/IBM/watson-machine-learning-samples/blob/df8e5122a521638cb37245254fe35d3a18cd3f59/cloud/notebooks/python_sdk/deployments/spss/Use%20SPSS%20and%20batch%20deployment%20with%20DB2%20to%20predict%20customer%20churn.ipynb)

### Data source reference types in Watson Machine Learning ###

Data source reference types are referenced in Watson Machine Learning requests to represent input data and results locations\. Use `data_asset` and `connection_asset` for these types of data sources:

<!-- <ul> -->

 *  Cloud Object Storage
 *  Db2
 *  Database data

<!-- </ul> -->

**Notes:**  

<!-- <ul> -->

 *  For Decision Optimization, the reference type is `url`\.

<!-- </ul> -->

#### Example data\_asset payload ####

    {"input_data_references": [{
        "type": "data_asset",
        "connection": {
        },
        "location": {
            "href": "/v2/assets/<asset_id>?space_id=<space_id>"
        }
    }]

#### Example connection\_asset payload ####

    "input_data_references": [{
        "type": "connection_asset",
        "connection": {
            "id": "<connection_guid>"
        },
        "location": {
            "bucket": "<bucket_name>",
            "file_name": "<directory_name>/<file_name>"
        }
        <other wdp-properties supported by runtimes>
    }]

For more information, see:

<!-- <ul> -->

 *  Watson Machine Learning [REST API](https://cloud.ibm.com/apidocs/machine-learning)

<!-- </ul> -->

## Using data from the Cloud Object Storage service ##

Cloud Object Storage service can be used with deployment jobs through a connected data asset or a connection asset\. To use data from the Cloud Object Storage service:

<!-- <ol> -->

1.  Create a connection to IBM Cloud Object Storage by adding a **Connection** to your project or space and selecting Cloud Object Storage (infrastructure) or Cloud Object Storage as the connector\. Provide the secret key, access key, and login URL\.
    
    Note:When you are creating a connection to Cloud Object Storage or Cloud Object Storage (Infrastructure), you must specify both `access_key` and `secret_key`. If `access_key` and `secret_key` are not specified, downloading the data from that connection doesn't work in a batch deployment job. For reference, see [IBM Cloud Object Storage connection](https://dataplatform.cloud.ibm.com/docs/content/wsj/manage-data/conn-cos.html) and [IBM Cloud Object Storage (infrastructure) connection](https://dataplatform.cloud.ibm.com/docs/content/wsj/manage-data/conn-cos-infra.html).
2.  Add input and output files to the deployment space as connected data by using the Cloud Object Storage connection that you created\.

<!-- </ol> -->

**Parent topic:**[Assets in deployment spaces](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-space-add-assets-all.html)

<!-- </article "role="article" "> -->