Ejemplo n.º 1
0
    def submit(self,
               workflow_uuid='',
               experiment='',
               image='',
               cmd='',
               prettified_cmd='',
               workflow_workspace='',
               job_name='',
               cvmfs_mounts='false',
               compute_backend=None,
               kerberos=False,
               kubernetes_uid=None):
        """Submit a job to RJC API.

        :param job_name: Name of the job.
        :param experiment: Experiment the job belongs to.
        :param image: Identifier of the Docker image which will run the job.
        :param cmd: String which represents the command to execute. It can be
            modified by the workflow engine i.e. prepending ``cd /some/dir/``.
        :prettified_cmd: Original command submitted by the user.
        :workflow_workspace: Path to the workspace of the workflow.
        :cvmfs_mounts: String with CVMFS volumes to mount in job pods.
        :compute_backend: Job compute backend.
        :kerberos: Decides if kerberos should be provided for job container.
        :kubernetes_uid: Overwrites the default user id in the job container.
        :return: Returns a dict with the ``job_id``.
        """
        job_spec = {
            'docker_img': image,
            'cmd': cmd,
            'prettified_cmd': prettified_cmd,
            'env_vars': {},
            'workflow_workspace': workflow_workspace,
            'job_name': job_name,
            'cvmfs_mounts': cvmfs_mounts,
            'workflow_uuid': workflow_uuid,
        }

        if compute_backend:
            job_spec['compute_backend'] = compute_backend

        if kerberos:
            job_spec['kerberos'] = kerberos

        if kubernetes_uid:
            job_spec['kubernetes_uid'] = kubernetes_uid

        response, http_response = self._client.jobs.create_job(job=job_spec).\
            result()
        if http_response.status_code == 400:
            raise HTTPBadRequest(
                'Bad request to create a job. Error: {}'.format(
                    http_response.data))
        elif http_response.status_code == 500:
            raise HTTPInternalServerError(
                'Internal Server Error. Error: {}'.format(http_response.data))
        return response
Ejemplo n.º 2
0
 def check_if_cached(self, job_spec, step, workflow_workspace):
     """Check if job result is in cache."""
     response, http_response = self._client.job_cache.check_if_cached(
         job_spec=json.dumps(job_spec),
         workflow_json=json.dumps(step),
         workflow_workspace=workflow_workspace,
     ).result()
     if http_response.status_code == 400:
         raise HTTPBadRequest(
             "Bad request to check cache. Error: {}".format(
                 http_response.data))
     elif http_response.status_code == 500:
         raise HTTPInternalServerError(
             "Internal Server Error. Error: {}".format(http_response.data))
     return http_response
Ejemplo n.º 3
0
    def submit(self,
               workflow_uuid='',
               experiment='',
               image='',
               cmd='',
               prettified_cmd='',
               workflow_workspace='',
               job_name='',
               cvmfs_mounts='false'):
        """Submit a job to RJC API.

        :param name: Name of the job.
        :param experiment: Experiment the job belongs to.
        :param image: Identifier of the Docker image which will run the job.
        :param cmd: String which represents the command to execute. It can be
            modified by the workflow engine i.e. prepending ``cd /some/dir/``.
        :prettified_cmd: Original command submitted by the user.
        :workflow_workspace: Path to the workspace of the workflow.
        :cvmfs_mounts: String with CVMFS volumes to mount in job pods.
        :return: Returns a dict with the ``job_id``.
        """
        job_spec = {
            'experiment': experiment,
            'docker_img': image,
            'cmd': cmd,
            'prettified_cmd': prettified_cmd,
            'env_vars': {},
            'workflow_workspace': workflow_workspace,
            'job_name': job_name,
            'cvmfs_mounts': cvmfs_mounts,
            'workflow_uuid': workflow_uuid
        }

        response, http_response = self._client.jobs.create_job(job=job_spec).\
            result()
        if http_response.status_code == 400:
            raise HTTPBadRequest(
                'Bad request to create a job. Error: {}'.format(
                    http_response.data))
        elif http_response.status_code == 500:
            raise HTTPInternalServerError(
                'Internal Server Error. Error: {}'.format(http_response.data))
        return response
Ejemplo n.º 4
0
    def submit(
        self,
        workflow_uuid="",
        experiment="",
        image="",
        cmd="",
        prettified_cmd="",
        workflow_workspace="",
        job_name="",
        cvmfs_mounts="false",
        compute_backend=None,
        kerberos=False,
        kubernetes_uid=None,
        unpacked_img=False,
        voms_proxy=False,
        htcondor_max_runtime="",
        htcondor_accounting_group="",
    ):
        """Submit a job to RJC API.

        :param job_name: Name of the job.
        :param experiment: Experiment the job belongs to.
        :param image: Identifier of the Docker image which will run the job.
        :param cmd: String which represents the command to execute. It can be
            modified by the workflow engine i.e. prepending ``cd /some/dir/``.
        :prettified_cmd: Original command submitted by the user.
        :workflow_workspace: Path to the workspace of the workflow.
        :cvmfs_mounts: String with CVMFS volumes to mount in job pods.
        :compute_backend: Job compute backend.
        :kerberos: Decides if kerberos should be provided for job container.
        :voms_proxy: Decides if grid proxy should be provided for job
            container.
        :kubernetes_uid: Overwrites the default user id in the job container.
        :unpacked_img: Decides if unpacked iamges should be used.
        :return: Returns a dict with the ``job_id``.
        :htcondor_max_runtime: Maximum runtime of a HTCondor job.
        :htcondor_accounting_group: Accounting group of a HTCondor job.
        """
        job_spec = {
            "docker_img": image,
            "cmd": cmd,
            "prettified_cmd": prettified_cmd,
            "env_vars": {},
            "workflow_workspace": workflow_workspace,
            "job_name": job_name,
            "cvmfs_mounts": cvmfs_mounts,
            "workflow_uuid": workflow_uuid,
        }

        if compute_backend:
            job_spec["compute_backend"] = compute_backend

        if kerberos:
            job_spec["kerberos"] = kerberos

        if voms_proxy:
            job_spec["voms_proxy"] = voms_proxy

        if kubernetes_uid:
            job_spec["kubernetes_uid"] = kubernetes_uid

        if unpacked_img:
            job_spec["unpacked_img"] = unpacked_img

        if htcondor_max_runtime:
            job_spec["htcondor_max_runtime"] = htcondor_max_runtime

        if htcondor_accounting_group:
            job_spec["htcondor_accounting_group"] = htcondor_accounting_group

        response, http_response = self._client.jobs.create_job(
            job=job_spec).result()
        if http_response.status_code == 400:
            raise HTTPBadRequest(
                "Bad request to create a job. Error: {}".format(
                    http_response.data))
        elif http_response.status_code == 500:
            raise HTTPInternalServerError(
                "Internal Server Error. Error: {}".format(http_response.data))
        return response