예제 #1
0
def upload_files(id, file):
    """Upload files to data"""
    api = rest.DataApi(configuration.get_api_client())
    for x in file:
        upload_info = object_storage.upload_file(api.api_client, x, 'Data')
        model = rest.ComponentsAddFileInputModel(file_name=upload_info.file_name, stored_path=upload_info.stored_path)
        api.add_data_file(id, model=model)
예제 #2
0
def upload_file(id, file_path):
    """Upload a file to training"""
    api = rest.TrainingApi(configuration.get_api_client())
    attached_info = object_storage.upload_file(api.api_client, file_path,
                                               'TrainingHistoryAttachedFiles')
    model = rest.ComponentsAddFileInputModel(
        file_name=attached_info.file_name,
        stored_path=attached_info.stored_path)
    api.add_training_file(id, model=model)
예제 #3
0
파일: data.py 프로젝트: netresj/kamonohashi
def do_upload_files(api, id, file):
    """
    :param rest.DataApi api:
    :param int id: data id
    :param list[string] file:
    """
    model = rest.DataApiModelsAddFilesInputModel(files=[])
    for x in file:
        upload_info = object_storage.upload_file(api.api_client, x, 'Data')
        model.files.append(rest.ComponentsAddFileInputModel(file_name=upload_info.file_name,
                                                            stored_path=upload_info.stored_path))
    api.add_data_file(id, model=model, _request_timeout=heavy_request_timeout(api.api_client))
예제 #4
0
def create(name, file, memo, tags):
    """Create new data"""
    api = rest.DataApi(configuration.get_api_client())
    model = rest.DataApiModelsCreateInputModel(memo=memo,
                                               name=name,
                                               tags=list(tags))
    result = api.create_data(model=model)
    for x in file:
        upload_info = object_storage.upload_file(api.api_client, x, 'Data')
        model = rest.ComponentsAddFileInputModel(
            file_name=upload_info.file_name,
            stored_path=upload_info.stored_path)
        api.add_data_file(result.id, model=model)
    print('created', result.id)
예제 #5
0
def build_history_files(id, data_id, source, memo, tags):
    """Build file structure for existing history"""
    api = rest.PreprocessingApi(configuration.get_api_client())
    for entry in os.listdir(source):
        if os.path.isdir(os.path.join(source, entry)):
            uploaded_files = []
            for root, _, files in os.walk(os.path.join(source, entry)):
                for file in files:
                    upload_info = object_storage.upload_file(
                        api.api_client, os.path.join(root, file), 'Data')
                    uploaded_files.append(
                        rest.ComponentsAddFileInputModel(
                            file_name=upload_info.file_name,
                            stored_path=upload_info.stored_path))
            model = rest.PreprocessingApiModelsAddOutputDataInputModel(
                files=uploaded_files, name=entry, memo=memo, tags=list(tags))
            api.add_preprocessing_history_files(id, data_id, model=model)

    api.complete_preprocessing_history(id, data_id)
예제 #6
0
파일: data.py 프로젝트: sinpcw/kamonohashi
def upload_file(api_client, id, file_path):
    api = rest.DataApi(api_client)
    upload_info = object_storage.upload_file(api_client, file_path, 'Data')
    model = rest.ComponentsAddFileInputModel(file_name=upload_info.file_name, stored_path=upload_info.stored_path)
    result = api.add_data_file(id, model=model)
    return result