Creating a Dataset Import Phase
Description
This phase integrates capabilities of the ModelArts dataset module, allowing you to import data to datasets. The dataset import phase is used to import data from a specified path to a dataset or a labeling job. The application scenarios are as follows:
- This phase is used for continuous data update. You can import raw data or labeled data to a labeling job and label the data in the labeling phase.
- Some labeled raw data can be directly imported to a dataset or labeling job, and the dataset with version information can be obtained in the dataset release phase.
Parameter Overview
You can use DatasetImportStep to create a dataset import phase. The following is an example of defining a DatasetImportStep.
Parameter |
Description |
Mandatory |
Data Type |
---|---|---|---|
name |
Name of a dataset import phase. The name contains a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-). It must start with a letter and must be unique in a workflow. |
Yes |
str |
inputs |
Inputs of the dataset import phase. |
Yes |
DatasetImportInput or DatasetImportInput list |
outputs |
Outputs of the dataset import phase. |
Yes |
DatasetImportOutput or DatasetImportOutput list |
properties |
Configurations for dataset import. |
Yes |
ImportDataInfo |
title |
Title for frontend display. |
No |
str |
description |
Description of the dataset import phase. |
No |
str |
policy |
Phase execution policy. |
No |
StepPolicy |
depend_steps |
Dependent phases. |
No |
Step or step list |
Parameter |
Description |
Mandatory |
Data Type |
---|---|---|---|
name |
Input name of the dataset import phase. The name can contain a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-), and must start with a letter. The input name of a step must be unique. |
Yes |
str |
data |
Input data object of the dataset import phase. |
Yes |
Dataset, OBS, or labeling job object. Currently, only Dataset, DatasetConsumption, DatasetPlaceholder, OBSPath, OBSConsumption, OBSPlaceholder, LabelTask, LabelTaskPlaceholder, LabelTaskConsumption, and DataConsumptionSelector are supported. |
Parameter |
Description |
Mandatory |
Data Type |
---|---|---|---|
name |
Output name of the dataset import phase. The name can contain a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-), and must start with a letter. The output name of a step must be unique. |
Yes |
str |
Parameter |
Description |
Mandatory |
Data Type |
---|---|---|---|
annotation_format_config |
Configurations of the imported labeling format. |
No |
AnnotationFormatConfig |
excluded_labels |
Samples with specified labels are not imported. |
No |
Label list |
import_annotated |
Whether to import the labeled samples in the original dataset to the To Be Confirmed tab. The default value is false, indicating that the labeled samples in the original dataset are not imported to the To Be Confirmed tab. The options are as follows:
|
No |
bool |
import_annotations |
Whether to import labels. The options are as follows:
|
No |
bool |
import_samples |
Whether to import samples. The options are as follows:
|
No |
bool |
import_type |
Import mode. The options are as follows:
|
No |
ImportTypeEnum |
included_labels |
Samples with specified labels are imported. |
No |
Label list |
label_format |
Label format. This parameter is used only for text datasets. |
No |
LabelFormat |
Parameter |
Description |
Mandatory |
Data Type |
---|---|---|---|
format_name |
Name of a labeling format |
No |
AnnotationFormatEnum |
parameters |
Advanced parameters of the labeling format |
No |
AnnotationFormatParameters |
scene |
Labeling scenario, which is optional |
No |
LabelTaskTypeEnum |
Parameter |
Description |
Mandatory |
Data Type |
---|---|---|---|
difficult_only |
Whether to import only hard examples. The options are as follows:
|
No |
bool |
included_labels |
Samples with specified labels are imported. |
No |
Label list |
label_separator |
Separator between labels. By default, the comma (,) is used as the separator. The separator needs to be escaped. The separator can contain only one character, which must be a letter, a digit, or any of the following special characters: !@#$%^&*_=|?/':.;, |
No |
str |
sample_label_separator |
Separator between the text and label. By default, the Tab key is used as the separator. The separator needs to be escaped. The separator can contain only one character, which must be a letter, a digit, or any of the following special characters: !@#$%^&*_=|?/':.;, |
No |
str |
Examples
There are three scenarios:
- Scenario 1: Updating a dataset by importing data from a specified path
- You import labeled data (with label information) in a specified path to a dataset. Then, you can create a dataset release phase to release a version.
Data preparation: Create a dataset on the ModelArts console and upload labeled data to OBS.
from modelarts import workflow as wf # Use DatasetImportStep to import data in a specified path to a dataset and output the dataset. # Define a dataset. dataset = wf.data.DatasetPlaceholder(name="input_dataset") # Define OBS data. obs = wf.data.OBSPlaceholder(name = "obs_placeholder_name", object_type = "directory" ) # object_type must be file or directory. dataset_import = wf.steps.DatasetImportStep( name="data_import", # Name of the dataset import phase. The name contains a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-). It must start with a letter and must be unique in a workflow. title="Dataset Import", # Title, which defaults to the value of name inputs=[ wf.steps.DatasetImportInput(name="input_name_1", data=dataset), # The target dataset is configured when the workflow is running. You can also use wf.data.Dataset(dataset_name="dataset_name") for the data field. wf.steps.DatasetImportInput(name="input_name_2", data=obs) # Storage path to the imported dataset, configured when the workflow is running. You can also use wf.data.OBSPath(obs_path="obs_path") for the data field. ],# DatasetImportStep inputs outputs=wf.steps.DatasetImportOutput(name="output_name"), # DatasetImportStep outputs properties=wf.steps.ImportDataInfo( annotation_format_config=[ wf.steps.AnnotationFormatConfig( format_name=wf.steps.AnnotationFormatEnum.MA_IMAGE_CLASSIFICATION_V1, # Labeling format of labeled data, for example, image classification scene=wf.data.LabelTaskTypeEnum.IMAGE_CLASSIFICATION # Labeling scene ) ] ) ) workflow = wf.Workflow( name="dataset-import-demo", desc="this is a demo workflow", steps=[dataset_import] )
- You import unlabeled data in a specified path to a dataset. Then, you can add a labeling phase to label the imported data.
Data preparation: Create a dataset on the ModelArts console and upload unlabeled data to OBS.
from modelarts import workflow as wf # Use DatasetImportStep to import data in a specified path to a dataset and output the dataset. # Define a dataset. dataset = wf.data.DatasetPlaceholder(name="input_dataset") # Define OBS data. obs = wf.data.OBSPlaceholder(name = "obs_placeholder_name", object_type = "directory" ) # object_type must be file or directory. dataset_import = wf.steps.DatasetImportStep( name="data_import", # Name of the dataset import phase. The name contains a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-). It must start with a letter and must be unique in a workflow. title="Dataset Import", # Title, which defaults to the value of name inputs=[ wf.steps.DatasetImportInput(name="input_name_1", data=dataset), # The target dataset is configured when the workflow is running. You can also use wf.data.Dataset(dataset_name="dataset_name") for the data field. wf.steps.DatasetImportInput(name="input_name_2", data=obs) # Storage path to the imported dataset, configured when the workflow is running. You can also use wf.data.OBSPath(obs_path="obs_path") for the data field. ],# DatasetImportStep inputs outputs=wf.steps.DatasetImportOutput(name="output_name"), # DatasetImportStep outputs ) workflow = wf.Workflow( name="dataset-import-demo", desc="this is a demo workflow", steps=[dataset_import] )
- You import labeled data (with label information) in a specified path to a dataset. Then, you can create a dataset release phase to release a version.
- Scenario 2: Updating a labeling job by importing data from a specified path
- You import labeled data in a specified path to a labeling job. Then, you can create a dataset release phase to release a version.
Data preparation: Create a labeling job using a specified dataset and upload the labeled data to OBS.
from modelarts import workflow as wf # Use DatasetImportStep to import data in a specified path to a labeling job and output the labeling job. # Define a labeling job. label_task = wf.data.LabelTaskPlaceholder(name="label_task_placeholder_name") # Define the OBS data. obs = wf.data.OBSPlaceholder(name = "obs_placeholder_name", object_type = "directory" ) # object_type must be file or directory. dataset_import = wf.steps.DatasetImportStep( name="data_import", # Name of the dataset import phase. The name contains a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-). It must start with a letter and must be unique in a workflow. title="Dataset Import", # Title, which defaults to the value of name inputs=[ wf.steps.DatasetImportInput(name="input_name_1", data=label_task), # Labeling job object, configured when the workflow is running. You can also use wf.data.LabelTask(dataset_name="dataset_name", task_name="label_task_name") for the data field. wf.steps.DatasetImportInput(name="input_name_2", data=obs) # Storage path to the imported dataset, configured when the workflow is running. You can also use wf.data.OBSPath(obs_path="obs_path") for the data field. ],# DatasetImportStep inputs outputs=wf.steps.DatasetImportOutput(name="output_name"), # DatasetImportStep outputs properties=wf.steps.ImportDataInfo( annotation_format_config=[ wf.steps.AnnotationFormatConfig( format_name=wf.steps.AnnotationFormatEnum.MA_IMAGE_CLASSIFICATION_V1, # Labeling format of labeled data, for example, image classification scene=wf.data.LabelTaskTypeEnum.IMAGE_CLASSIFICATION # Labeling scene ) ] ) ) workflow = wf.Workflow( name="dataset-import-demo", desc="this is a demo workflow", steps=[dataset_import] )
- You import unlabeled data in a specified path to a labeling job. Then, you can add a labeling phase to label the imported data.
Data preparation: Create a labeling job using a specified dataset and upload the unlabeled data to OBS.
from modelarts import workflow as wf # Use DatasetImportStep to import data in a specified path to a labeling job and output the labeling job. # Define a labeling job. label_task = wf.data.LabelTaskPlaceholder(name="label_task_placeholder_name") # Define the OBS data. obs = wf.data.OBSPlaceholder(name = "obs_placeholder_name", object_type = "directory" ) # object_type must be file or directory. dataset_import = wf.steps.DatasetImportStep( name="data_import", # Name of the dataset import phase. The name contains a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-). It must start with a letter and must be unique in a workflow. title="Dataset Import", # Title, which defaults to the value of name inputs=[ wf.steps.DatasetImportInput(name="input_name_1", data=label_task), # Labeling job object, configured when the workflow is running. You can also use wf.data.LabelTask(dataset_name="dataset_name", task_name="label_task_name") for the data field. wf.steps.DatasetImportInput(name="input_name_2", data=obs) # Storage path to the imported dataset, configured when the workflow is running. You can also use wf.data.OBSPath(obs_path="obs_path") for the data field. ],# DatasetImportStep inputs outputs=wf.steps.DatasetImportOutput(name="output_name"), # DatasetImportStep outputs ) workflow = wf.Workflow( name="dataset-import-demo", desc="this is a demo workflow", steps=[dataset_import] )
- You import labeled data in a specified path to a labeling job. Then, you can create a dataset release phase to release a version.
- Scenario 3: Creating a dataset import phase using the outputs of the dataset creation phase.
from modelarts import workflow as wf # Use DatasetImportStep to import data in a specified path to a dataset and output the dataset. # Define the OBS data. obs = wf.data.OBSPlaceholder(name = "obs_placeholder_name", object_type = "directory" ) # object_type must be file or directory. dataset_import = wf.steps.DatasetImportStep( name="data_import", # Name of the dataset import phase. The name contains a maximum of 64 characters, including only letters, digits, underscores (_), and hyphens (-). It must start with a letter and must be unique in a workflow. title="Dataset Import", # Title, which defaults to the value of name inputs=[ wf.steps.DatasetImportInput(name="input_name_1", data=create_dataset.outputs["create_dataset_output"].as_input()), # The outputs of the dataset creation phase are used as the inputs of the dataset import phase. wf.steps.DatasetImportInput(name="input_name_2", data=obs) # Storage path to the imported dataset, configured when the workflow is running. You can also use wf.data.OBSPath(obs_path="obs_path") for the data field. ],# DatasetImportStep inputs outputs=wf.steps.DatasetImportOutput(name="output_name"), # DatasetImportStep outputs depend_steps=create_dataset # Preceding dataset creation phase ) # create_dataset is an instance of wf.steps.CreateDatasetStep. create_dataset_output is the name field value of wf.steps.CreateDatasetOutput. workflow = wf.Workflow( name="dataset-import-demo", desc="this is a demo workflow", steps=[dataset_import] )
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot