Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating a Dataset Import Phase

Updated on 2024-10-29 GMT+08:00

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.

Table 1 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

Table 2 DatasetImportInput

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.

Table 3 DatasetImportOutput

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

Table 4 ImportDataInfo

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:

  • true: The labeled samples in the original dataset are imported to the To Be Confirmed tab.
  • false: The labeled samples in the original dataset are not imported to the To Be Confirmed tab.

No

bool

import_annotations

Whether to import labels. The options are as follows:

  • true: The labels are imported. (Default)
  • false: The labels are not imported.

No

bool

import_samples

Whether to import samples. The options are as follows:

  • true: The samples are imported. (Default)
  • false: The samples are not imported.

No

bool

import_type

Import mode. The options are as follows:

  • dir: imported from an OBS path
  • manifest: imported from a manifest file

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

Table 5 AnnotationFormatConfig

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

Table 6 AnnotationFormatParameters

Parameter

Description

Mandatory

Data Type

difficult_only

Whether to import only hard examples. The options are as follows:

  • true: Only hard examples are imported.
  • false: All the samples are imported. (Default)

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]
      )
  • 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]
      )
  • 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]
    )

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback