예제 #1
0
def create_pipeline_input_file(organization_pipeline, filename, stream):
    """ Create a OrganizationPipelineInputFile from a stream. """
    if len(filename) < 2:
        raise ValueError("filename too short")
    if len(filename) > OrganizationPipelineInputFile.name.type.length:
        raise ValueError("filename too long")

    sname = quote(filename)
    input_file_uuid = uuid.uuid4().hex
    upload_stream(
        f"{organization_pipeline.uuid}/{input_file_uuid}-{sname}",
        stream,
    )

    input_file = OrganizationPipelineInputFile(uuid=input_file_uuid, name=filename)
    organization_pipeline.organization_pipeline_input_files.append(input_file)

    db.session.commit()

    return input_file
예제 #2
0
def create_pipeline_run_artifact(run_uuid, filename, stream):
    """ Create a PipelineRunArtifact from a stream. """
    pipeline_run = find_pipeline_run(run_uuid)
    if pipeline_run is None:
        raise ValueError("pipeline run not found")

    sname = quote(filename)
    artifact_uuid = uuid.uuid4().hex

    upload_stream(
        f"{pipeline_run.pipeline.uuid}/{run_uuid}/{artifact_uuid}-{sname}",
        stream,
    )

    artifact = PipelineRunArtifact(uuid=artifact_uuid, name=filename)
    pipeline_run.pipeline_run_artifacts.append(artifact)

    db.session.commit()

    return artifact
예제 #3
0
def update_organization_logo(organization, data):
    if not isinstance(organization, Organization):
        raise BadRequestError("Invalid organization")

    upload_stream(f"logos/{organization.uuid}", data)
예제 #4
0
def update_user_avatar(user, data):
    if not isinstance(user, User):
        raise BadRequestError("Invalid user")

    upload_stream(f"avatars/{user.uuid}", data)