Example #1
0
    def add_job(self, wf, job_dag, mvm):
        """
        Create a PythonTask, add it to the workflow, and update the DagNode to
        contain a reference to the task.

        Args:
            wf (jobmon.client.swarm.workflow.workflow): jobmon workflow
            job_dag (dict[str, DagNode]): a mapping of job name to DagNode
            mvm (cascade_ode.importer.Importer.model_version_meta): a dataframe
                of model settings

        The varnish job does the following:
           1. Uploads fits
           2. Uploads adjusted data
           3. Computes fit statistics
           4. Uploads fit statistics
           5. Attempts to generate diagnostic plots
           5. Computes and uploads finals (save-results)
           6. Updates the status of the model to finished
        """
        slots, memory, runtime = sge.cluster_limits('varnish',
                                                    mvm,
                                                    details=self.details)
        environment_variables_to_add = settings['env_variables']
        environment_variables_to_add['OMP_NUM_THREADS'] = slots

        # Varnish memory allocation shouldn't change with job size, and
        # large memory allocations will prohibit scheduling.
        _, runtime = sge.update_ME_specific_allocations(
            modelable_entity_id=mvm.modelable_entity_id.unique()[0],
            memory=memory,
            runtime=runtime)

        upstream_tasks = []
        for upstream_jobname in self.upstream_jobs:
            upstream_tasks.extend(job_dag[upstream_jobname].task)

        task = PythonTask(script=self.script,
                          args=self.args,
                          name=self.job_name,
                          upstream_tasks=upstream_tasks,
                          env_variables=environment_variables_to_add,
                          num_cores=slots,
                          max_runtime_seconds=runtime,
                          queue=queue_from_runtime(runtime),
                          m_mem_free=f"{memory}G",
                          max_attempts=self.max_attempts,
                          tag='upload',
                          j_resource=True)
        task.context_args = add_if_set(self.host_type)

        self.task.append(task)
        wf.add_task(task)
Example #2
0
    def add_job(self, wf, job_dag, mvm):
        """
        Create a PythonTask, add it to the workflow, and update the DagNode to
        contain a reference to the task.

        Args:
            wf (jobmon.client.swarm.workflow.workflow): jobmon workflow
            job_dag (dict[str, DagNode]): a mapping of job name to DagNode
            mvm (cascade_ode.importer.Importer.model_version_meta): a dataframe
                of model settings
        """
        num_children = self.details['num_children']
        slots, memory, runtime = sge.cluster_limits('node',
                                                    mvm,
                                                    num_children,
                                                    details=self.details)
        environment_variables_to_add = settings['env_variables']
        environment_variables_to_add['OMP_NUM_THREADS'] = slots

        memory, runtime = sge.update_ME_specific_allocations(
            modelable_entity_id=mvm.modelable_entity_id.unique()[0],
            memory=memory,
            runtime=runtime)

        upstream_tasks = []
        for upstream_jobname in self.upstream_jobs:
            upstream_tasks.extend(job_dag[upstream_jobname].task)

        task = PythonTask(script=self.script,
                          args=self.args,
                          name=self.job_name,
                          upstream_tasks=upstream_tasks,
                          env_variables=environment_variables_to_add,
                          num_cores=slots,
                          max_runtime_seconds=runtime,
                          queue=queue_from_runtime(runtime),
                          m_mem_free=f"{memory}G",
                          max_attempts=self.max_attempts,
                          tag='node',
                          j_resource=False)
        task.context_args = add_if_set(self.host_type)

        self.task.append(task)
        wf.add_task(task)