:py:mod:`k8s_client.views.users.jobs` ===================================== .. py:module:: k8s_client.views.users.jobs Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: k8s_client.views.users.jobs.upload_file_for_job k8s_client.views.users.jobs.start_job k8s_client.views.users.jobs.kill_job k8s_client.views.users.jobs.cancel_job k8s_client.views.users.jobs.delete_job k8s_client.views.users.jobs.get_jobs k8s_client.views.users.jobs.get_jobs_count k8s_client.views.users.jobs.post_jobs .. py:function:: upload_file_for_job(username=None, job_uuid=None) Upload a file for a reserved job Parameters ---------- ``"username"``: `string`, optional Name of the owner user for which to upload the file ``"job_uuid"``: `string` UUID of the job to upload the file Returns ------- - ``[code: 404]`` Error message if: - ``username`` is NOT inside the DB - ``job_uuid`` is NOT inside the DB or is not `reserved` - ``[code: 200]`` `OK` if the job is in `reserved` status .. py:function:: start_job(username=None, job_uuid=None) Start a reserved job Parameters ---------- ``"username"``: `string`, optional Name of the owner user for which to start the job ``"job_uuid"``: `string` UUID of the job to start Returns ------- - ``[code: 404]`` Error message if: - ``username`` is NOT inside the DB - ``job_uuid`` is NOT inside the DB or is not `reserved` - ``[code: 200]`` `OK` if the job is in `reserved` status .. py:function:: kill_job(username=None, job_uuid=None) Kills a running job Parameters ---------- ``"username"``: `string`, optional Name of the owner user for which to kill the job ``"job_uuid"``: `string` UUID of the job to kill Returns ------- - ``[code: 404]`` Error message if: - ``username`` is NOT inside the DB - ``job_uuid`` is NOT inside the DB or is not running - ``[code: 200]`` `OK` if the job is in `running` status .. py:function:: cancel_job(username=None, job_uuid=None) Cancel a pending job Parameters ---------- ``"username"``: `string`, optional Name of the owner user for which to cancel the job ``"job_uuid"``: `string` UUID of the job to cancel Returns ------- - ``[code: 404]`` Error message if: - ``username`` is NOT inside the DB - ``job_uuid`` is NOT inside the DB or is not in a `pending` status - ``[code: 200]`` `list` [`string`] Array containing the cancelled job if the job is in `pending` or `reserved` status - ``[code: 200]`` `list` [] empty list otherwise .. py:function:: delete_job(username=None, job_uuid=None) Deletes a job Parameters ---------- ``"username"``: `string`, optional Name of the owner user for which to delete the job ``"job_uuid"``: `string` UUID of the job to delete Returns ------- - ``[code: 404]`` Error message if: - ``username`` is NOT inside the DB - ``job_uuid`` is NOT inside the DB - ``[code: 200]`` `list` [`string`] Array containing the deleted job .. py:function:: get_jobs(username=None, limit=None, offset=0) Get user jobs list Parameters ---------- ``"username"``: `string`, optional Name of the owner user for which to get the jobs count ``"offset"``: `int`, optional Offset of the jobs list items count. Used for pagination ``"limit"``: `int`, optional Limit of the jobs list items count. Used for pagination Query parameters: ----------------- ``"image_id"``: `int`, optional Image Id for which to get the jobs count ``"context_id"``: `int`, optional Context Id for which to get the jobs count ``"status"``: `string`, optional Status for which to get the jobs count ``"image_tag_id"``: `int`, optional Image tag Id for which to get the jobs count ``"node_id"``: `int`, optional Node Id for which to get the jobs count ``"node_name"``: `string`, optional Node Name for which to get the jobs count ``"paradigm"``: `string`, optional Paradigm for which to get the jobs count ``"uuid"``: `string`, optional UUID for which to get the jobs count Returns ------- - ``[code: 406]`` Error message if: - ``username`` is NOT inside the DB - ``[code: 200]`` `int` Count of user jobs otherwise .. py:function:: get_jobs_count(username=None) Get user jobs count Parameters ---------- ``"username"``: `string`, Name of the owner user for which to get the jobs count Returns ------- - ``[code: 406]`` Error message if: - ``username`` is NOT inside the DB - ``[code: 200]`` `int` Count of user jobs otherwise .. py:function:: post_jobs(username=None) Creates a new job Parameters ---------- **Request Body** : `json` JSON containing data for the data: ``"cores_to_use"``: `int` Number of cores to use to run the application ``"context_name"``: `string` Name of the context to use to run the application ``"docker_image_name"``: `string` Name of the image representing the application to run ``"docker_image_tag"`` : `string`, Version of the image representing the application to run. **Semver** ``"username"``: `string`, Name of the owner user to use to run the application ``"paradigm"``: `string`, Paradigm to use. Values allowed: mpi | openmp ``"env_variables"``: `string` String representing the list of variables to pass to the application. The list will be of the form "name1=value1, ..., nameK=valueK" All the variables will be instanced inside the environment where the application runs ``"new_job_status"`` : `string`, optional - String representing the status of the new job. Default is "pending" - Accepted values: `pending`, `reserved` Returns ------- - ``[code: 406]`` Error message if: - ``context_name`` is NOT inside the DB - ``paradigm`` is NOT valid - ``username`` is NOT inside the DB - ``cores_to_use`` is a number that overcomes the available cores for the selected context - ``new_job_status`` is NOT valid - ``[code: 200]`` `dict` [`str`, `str`] if ``INPUT`` is valid Examples -------- >>> Body = { "cores_to_use": 30, "context_name": "context.dev.k8s.master.dafni.hydra.org.uk", "docker_image_name": "umwrg/openmp-test-2022", "docker_image_tag" : "0.0.12", "username": "a86302gb", "paradigm": "openmp", "env_variables": "API_USER=pippo, NP=75" } Returns { "job_uuid": "187fe2b9-5003-406f-8bd5-7a7931752e7d", "log_file_name": "a86302gb.187fe2b9-5003-406f-8bd5-7a7931752e7d.log" }