def submit_async():  # noqa: E501
    """Send an asyncronous operation

     # noqa: E501


    :rtype: InlineResponse202
    """
    shared_directory = '/mnt/shared'
    task_write = tasks.CustomTask(
        'download-file',
        'workflows-extract-download',
        url='https://github.com/MetaCell/cloud-harness/blob/master/README.md')
    task_print = tasks.CustomTask('print-file',
                                  'samples-print-file',
                                  file_path=shared_directory + '/README.md')
    op = operations.PipelineOperation('test-custom-connected-op-',
                                      (task_write, task_print),
                                      shared_directory=shared_directory)

    submitted = op.execute()
    if not op.is_error():
        return InlineResponse202(task=InlineResponse202Task(
            href=op.get_operation_update_url(), name=submitted.name)), 202
    else:
        return 'Error submitting operation', 500
Example #2
0
def create_operation(workspace, workspace_resource):
    resources = {
        'requests': {
            'memory': '256Mi',
            'cpu': '250m'
        },
        'limits': {
            'memory': '2048Mi',
            'cpu': '2500m'
        }
    }

    workspace_pvc_name = WorkspaceRepository().get_pvc_name(workspace)
    shared_directory = f'{workspace_pvc_name}:/project_download'

    download_task = tasks.CustomTask(name='osb-download-file',
                                     image_name='workflows-extract-download',
                                     url=workspace_resource.location,
                                     shared_directory=shared_directory,
                                     folder=workspace_resource.folder)

    op = operations.PipelineOperation(basename=f'osb-download-file-job',
                                      tasks=(download_task, ),
                                      shared_directory=shared_directory,
                                      folder=workspace_resource.folder,
                                      shared_volume_size=100,
                                      on_exit_notify={
                                          'queue': 'osb-download-file-queue',
                                          'payload': str(workspace_resource.id)
                                      })
    workflow = op.execute()
Example #3
0
def create_task(image_name, workspace_id, **kwargs):
    pvc_name = WorkspaceService.get_pvc_name(workspace_id)
    shared_directory = f"{pvc_name}:/project_download"
    return tasks.CustomTask(
        name=f"{image_name}-{str(uuid.uuid4())[:8]}",
        image_name=image_name,
        shared_directory=shared_directory,
        workspace_id=workspace_id,
        **kwargs,
    )
def submit_sync_with_results(a=1, b=2):  # noqa: E501
    """Send a synchronous operation and get results using the event queue. Just a sum, but in the cloud

     # noqa: E501

    :param a: first number to sum
    :type a: float
    :param b: second number to sum
    :type b: float

    :rtype: str
    """
    task = tasks.CustomTask('test-sum', 'samples-sum', a=a, b=b)
    try:
        op = operations.DistributedSyncOperationWithResults(
            'test-sync-op-results-', task)
        result = op.execute()
        return result
    except Exception as e:
        return jsonify(str(e)), 200
def submit_sync():  # noqa: E501
    """Send a syncronous operation

     # noqa: E501


    :rtype: str
    """
    task = tasks.CustomTask(
        'download-file',
        'workflows-extract-download',
        url='https://github.com/MetaCell/cloud-harness/blob/master/README.md')

    op = operations.DistributedSyncOperation('test-sync-op-', task)
    try:
        workflow = op.execute()
        return workflow.raw.to_dict()
    except Exception as e:
        log.error('Error submitting sync operation', exc_info=True)
        return 'Error submitting operation: %s' % e, 500