github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/modelarts/v2/dataset/results.go (about)

     1  package dataset
     2  
     3  import "github.com/chnsz/golangsdk/pagination"
     4  
     5  const (
     6  	StatusInit         = "INIT"
     7  	StatusCreating     = "CREATING"
     8  	StatusStarting     = "STARTING"
     9  	StatusStopping     = "STOPPING"
    10  	StatusDeleting     = "DELETING"
    11  	StatusRunning      = "RUNNING"
    12  	StatusStopped      = "STOPPED"
    13  	StatusSnapshotting = "SNAPSHOTTING"
    14  	StatusCreateFailed = "CREATE_FAILED"
    15  	StatusStartFailed  = "START_FAILED"
    16  	StatusDeleteFailed = "DELETE_FAILED"
    17  	StatusError        = "ERROR"
    18  	StatusDeleted      = "DELETED"
    19  	StatusFrozen       = "FROZEN"
    20  )
    21  
    22  type CreateResp struct {
    23  	DatasetId    string `json:"dataset_id"`
    24  	ErrorCode    string `json:"error_code"`
    25  	ErrorMsg     string `json:"error_msg"`
    26  	ImportTaskId string `json:"import_task_id"`
    27  }
    28  
    29  type Dataset struct {
    30  	AnnotatedSampleCount    int                    `json:"annotated_sample_count"`
    31  	AnnotatedSubSampleCount int                    `json:"annotated_sub_sample_count"`
    32  	ContentLabeling         bool                   `json:"content_labeling"`
    33  	CreateTime              int                    `json:"create_time"`
    34  	CurrentVersionId        string                 `json:"current_version_id"`
    35  	CurrentVersionName      string                 `json:"current_version_name"`
    36  	DataFormat              string                 `json:"data_format"`
    37  	DataSources             []DataSource           `json:"data_sources"`
    38  	DataStatistics          map[string]interface{} `json:"data_statistics"`
    39  	DataUpdateTime          int                    `json:"data_update_time"`
    40  	DatasetFormat           int                    `json:"dataset_format"`
    41  	DatasetId               string                 `json:"dataset_id"`
    42  	DatasetName             string                 `json:"dataset_name"`
    43  	DatasetTags             []string               `json:"dataset_tags"`
    44  	DatasetType             int                    `json:"dataset_type"`
    45  	DatasetVersionCount     int                    `json:"dataset_version_count"`
    46  	DeletedSampleCount      int                    `json:"deleted_sample_count"`
    47  	DeletionStats           map[string]int         `json:"deletion_stats"`
    48  	Description             string                 `json:"description"`
    49  	EnterpriseProjectId     string                 `json:"enterprise_project_id"`
    50  	ExistRunningTask        bool                   `json:"exist_running_task"`
    51  	ExistWorkforceTask      bool                   `json:"exist_workforce_task"`
    52  	FeatureSupports         []string               `json:"feature_supports"`
    53  	ImportData              bool                   `json:"import_data"`
    54  	ImportTaskId            string                 `json:"import_task_id"`
    55  	InnerAnnotationPath     string                 `json:"inner_annotation_path"`
    56  	InnerDataPath           string                 `json:"inner_data_path"`
    57  	InnerLogPath            string                 `json:"inner_log_path"`
    58  	InnerTaskPath           string                 `json:"inner_task_path"`
    59  	InnerTempPath           string                 `json:"inner_temp_path"`
    60  	InnerWorkPath           string                 `json:"inner_work_path"`
    61  	LabelTaskCount          int                    `json:"label_task_count"`
    62  	Labels                  []Label                `json:"labels"`
    63  	LoadingSampleCount      int                    `json:"loading_sample_count"`
    64  	Managed                 bool                   `json:"managed"`
    65  	NextVersionNum          int                    `json:"next_version_num"`
    66  	RunningTasksId          []string               `json:"running_tasks_id"`
    67  	Schema                  []Field                `json:"schema"`
    68  	Status                  int                    `json:"status"`
    69  	ThirdPath               string                 `json:"third_path"`
    70  	TotalSampleCount        int                    `json:"total_sample_count"`
    71  	TotalSubSampleCount     int                    `json:"total_sub_sample_count"`
    72  	UnconfirmedSampleCount  int                    `json:"unconfirmed_sample_count"`
    73  	UpdateTime              int                    `json:"update_time"`
    74  	Versions                []Version              `json:"versions"`
    75  	WorkPath                string                 `json:"work_path"`
    76  	WorkPathType            int                    `json:"work_path_type"`
    77  	WorkforceDescriptor     []WorkforceDescriptor  `json:"workforce_descriptor"`
    78  	WorkforceTaskCount      int                    `json:"workforce_task_count"`
    79  	WorkspaceId             string                 `json:"workspace_id"`
    80  }
    81  
    82  type Version struct {
    83  	AddSampleCount               int                    `json:"add_sample_count"`
    84  	AnalysisCachePath            string                 `json:"analysis_cache_path"`
    85  	AnalysisStatus               int                    `json:"analysis_status"`
    86  	AnalysisTaskId               string                 `json:"analysis_task_id"`
    87  	AnnotatedSampleCount         int                    `json:"annotated_sample_count"`
    88  	AnnotatedSubSampleCount      int                    `json:"annotated_sub_sample_count"`
    89  	ClearHardProperty            bool                   `json:"clear_hard_property"`
    90  	Code                         string                 `json:"code"`
    91  	CreateTime                   int                    `json:"create_time"`
    92  	Crop                         bool                   `json:"crop"`
    93  	CropPath                     string                 `json:"crop_path"`
    94  	CropRotateCachePath          string                 `json:"crop_rotate_cache_path"`
    95  	DataAnalysis                 map[string]interface{} `json:"data_analysis"`
    96  	DataPath                     string                 `json:"data_path"`
    97  	DataStatistics               map[string]interface{} `json:"data_statistics"`
    98  	DataValidate                 bool                   `json:"data_validate"`
    99  	DeletedSampleCount           int                    `json:"deleted_sample_count"`
   100  	DeletionStats                map[string]int         `json:"deletion_stats"`
   101  	Description                  string                 `json:"description"`
   102  	ExportImages                 bool                   `json:"export_images"`
   103  	ExtractSerialNumber          bool                   `json:"extract_serial_number"`
   104  	IncludeDatasetData           bool                   `json:"include_dataset_data"`
   105  	IsCurrent                    bool                   `json:"is_current"`
   106  	LabelStats                   []LabelStats           `json:"label_stats"`
   107  	LabelType                    string                 `json:"label_type"`
   108  	ManifestCacheInputPath       string                 `json:"manifest_cache_input_path"`
   109  	ManifestPath                 string                 `json:"manifest_path"`
   110  	Message                      string                 `json:"message"`
   111  	ModifiedSampleCount          int                    `json:"modified_sample_count"`
   112  	PreviousAnnotatedSampleCount int                    `json:"previous_annotated_sample_count"`
   113  	PreviousTotalSampleCount     int                    `json:"previous_total_sample_count"`
   114  	PreviousVersionId            string                 `json:"previous_version_id"`
   115  	ProcessorTaskId              string                 `json:"processor_task_id"`
   116  	ProcessorTaskStatus          int                    `json:"processor_task_status"`
   117  	RemoveSampleUsage            bool                   `json:"remove_sample_usage"`
   118  	Rotate                       bool                   `json:"rotate"`
   119  	RotatePath                   string                 `json:"rotate_path"`
   120  	SampleState                  string                 `json:"sample_state"`
   121  	StartProcessorTask           bool                   `json:"start_processor_task"`
   122  	Status                       int                    `json:"status"`
   123  	Tags                         []string               `json:"tags"`
   124  	TaskType                     int                    `json:"task_type"`
   125  	TotalSampleCount             int                    `json:"total_sample_count"`
   126  	TotalSubSampleCount          int                    `json:"total_sub_sample_count"`
   127  	TrainEvaluateSampleRatio     string                 `json:"train_evaluate_sample_ratio"`
   128  	UpdateTime                   int                    `json:"update_time"`
   129  	VersionFormat                string                 `json:"version_format"`
   130  	VersionId                    string                 `json:"version_id"`
   131  	VersionName                  string                 `json:"version_name"`
   132  	WithColumnHeader             bool                   `json:"with_column_header"`
   133  }
   134  
   135  type LabelStats struct {
   136  	Attributes  []LabelAttribute `json:"attributes"`
   137  	Count       int              `json:"count"`
   138  	Name        string           `json:"name"`
   139  	Property    LabelProperty    `json:"property"`
   140  	SampleCount int              `json:"sample_count"`
   141  	Type        int              `json:"type"`
   142  }
   143  
   144  type WorkforceDescriptor struct {
   145  	CurrentTaskId                 string   `json:"current_task_id"`
   146  	CurrentTaskName               string   `json:"current_task_name"`
   147  	RejectNum                     int      `json:"reject_num"`
   148  	Repetition                    int      `json:"repetition"`
   149  	IsSynchronizeAutoLabelingData bool     `json:"is_synchronize_auto_labeling_data"`
   150  	IsSynchronizeData             bool     `json:"is_synchronize_data"`
   151  	Workers                       []Worker `json:"workers"`
   152  	WorkforceId                   string   `json:"workforce_id"`
   153  	WorkforceName                 string   `json:"workforce_name"`
   154  }
   155  
   156  type ListResp struct {
   157  	Result []Dataset4List `json:"datasets"`
   158  	Total  int            `json:"total_number"`
   159  }
   160  
   161  type Dataset4List struct {
   162  	Dataset
   163  	DataUrl string           `json:"data_url"`
   164  	Samples []AnnotationFile `json:"samples"`
   165  }
   166  
   167  type AnnotationFile struct {
   168  	CreateTime int               `json:"create_time"`
   169  	DatasetId  string            `json:"dataset_id"`
   170  	Depth      int               `json:"depth"`
   171  	FileName   string            `json:"file_Name"`
   172  	FileId     string            `json:"file_id"`
   173  	FileType   string            `json:"file_type"`
   174  	Height     int               `json:"height"`
   175  	Size       int               `json:"size"`
   176  	Tags       map[string]string `json:"tags"`
   177  	Url        string            `json:"url"`
   178  	Width      int               `json:"width"`
   179  }
   180  
   181  type DatasetPage struct {
   182  	pagination.OffsetPageBase
   183  }
   184  
   185  // IsEmpty checks whether a RouteTablePage struct is empty.
   186  func (b DatasetPage) IsEmpty() (bool, error) {
   187  	arr, err := ExtractDatasets(b)
   188  	return len(arr) == 0, err
   189  }
   190  
   191  func ExtractDatasets(r pagination.Page) ([]Dataset4List, error) {
   192  	var s ListResp
   193  	err := (r.(DatasetPage)).ExtractInto(&s)
   194  	return s.Result, err
   195  }