Пример #1
0
 def testEnvParam(self):
     env_param = job_model.EnvParam('my_name', 'my_value')
     self.assertEqual('my_name', env_param.name)
     self.assertEqual('my_value', env_param.value)
Пример #2
0
def dsub_start_job(command,
                   job_name=None,
                   envs=None,
                   labels=None,
                   inputs=None,
                   inputs_recursive=None,
                   outputs=None,
                   outputs_recursive=None,
                   wait=False):

    envs = envs or {}
    labels = labels or {}
    inputs = inputs or {}
    inputs_recursive = inputs_recursive or {}
    outputs = outputs or {}
    outputs_recursive = outputs_recursive or {}

    labels['test-token'] = test_setup.TEST_TOKEN
    labels['test-name'] = test_setup.TEST_NAME

    logging = param_util.build_logging_param(test.LOGGING)
    job_resources = job_model.Resources(image='ubuntu',
                                        logging=logging,
                                        zones=['us-central1-*'])

    env_data = {job_model.EnvParam(k, v) for (k, v) in envs.items()}
    label_data = {job_model.LabelParam(k, v) for (k, v) in labels.items()}

    input_file_param_util = param_util.InputFileParamUtil('input')
    input_data = set()
    for (recursive, items) in ((False, inputs.items()),
                               (True, inputs_recursive.items())):
        for (name, value) in items:
            name = input_file_param_util.get_variable_name(name)
            input_data.add(
                input_file_param_util.make_param(name, value, recursive))

    output_file_param_util = param_util.OutputFileParamUtil('output')
    output_data = set()
    for (recursive, items) in ((False, outputs.items()),
                               (True, outputs_recursive.items())):
        for (name, value) in items:
            name = output_file_param_util.get_variable_name(name)
            output_data.add(
                output_file_param_util.make_param(name, value, recursive))

    job_params = {
        'envs': env_data,
        'inputs': input_data,
        'outputs': output_data,
        'labels': label_data,
    }
    task_descriptors = [
        job_model.TaskDescriptor({'task-id': None}, {
            'envs': set(),
            'labels': set(),
            'inputs': set(),
            'outputs': set(),
        }, job_model.Resources())
    ]

    return dsub.run(get_dsub_provider(),
                    job_resources,
                    job_params,
                    task_descriptors,
                    name=job_name,
                    command=command,
                    wait=wait,
                    disable_warning=True)
Пример #3
0
  user-id: dsubuser
""")

_ENV_LIST_JOB_DESCRIPTOR = job_model.JobDescriptor(
    job_metadata={
        'dsub-version': '0.1.4',
        'job-id': 'script_env--dsubuser--171122-142837-321721',
        'job-name': 'script_env_test.sh',
        'user-id': 'dsubuser',
        'create-time': CREATE_TIME
    },
    job_resources=job_model.Resources(
        logging='gs://b/dsub/sh/local/env_list/env_list/logging/env_list.log'),
    job_params={
        'envs': {
            job_model.EnvParam('VAR1', 'VAL1'),
            job_model.EnvParam('VAR2', 'VAL2'),
            job_model.EnvParam('VAR3', 'VAL3'),
            job_model.EnvParam('VAR4', 'VAL4'),
            job_model.EnvParam('VAR5', 'VAL5'),
        },
        'labels': set(),
        'inputs': set(),
        'outputs': set(),
        'mounts': set(),
    },
    task_descriptors=[
        job_model.TaskDescriptor(
            task_metadata={'task-id': None},
            task_resources=job_model.Resources(
                logging_path=