pyfarm.master.api.jobtypes module¶
Jobtypes¶
This module defines an API for managing and querying jobtypes
-
class
pyfarm.master.api.jobtypes.
JobTypeCodeAPI
[source]¶ Bases:
flask.views.MethodView
-
get
(jobtype_name, version)[source]¶ A
GET
to this endpoint will return just the python code for this version of the specified jobtype.-
GET
/api/v1/jobtypes/[<str:name>|<int:id>]/versions/<int:version>/code HTTP/1.1
¶ Request
GET /api/v1/jobtypes/TestJobType/versions/1/code HTTP/1.1 Accept: text/x-python
Response
HTTP/1.1 200 OK Content-Type: text/x-python from pyfarm.jobtypes.core.jobtype import JobType class TestJobType(JobType): def get_command(self): return "/usr/bin/touch" def get_arguments(self): return [os.path.join( self.assignment_data["job"]["data"]["path"], "%04d" % self.assignment_data["tasks"][0]["frame"])]
Statuscode 200: no error Statuscode 404: jobtype or version not found -
-
methods
= ['GET']¶
-
-
class
pyfarm.master.api.jobtypes.
JobTypeIndexAPI
[source]¶ Bases:
flask.views.MethodView
-
get
()[source]¶ A
GET
to this endpoint will return a list of registered jobtypes.-
GET
/api/v1/jobtypes/ HTTP/1.1
¶ Request
GET /api/v1/jobtypes/ HTTP/1.1 Accept: application/json
Response
HTTP/1.1 200 OK Content-Type: application/json [ { "id": 1, "name": "TestJobType" } ]
Statuscode 200: no error -
-
methods
= ['GET', 'POST']¶
-
post
()[source]¶ A
POST
to this endpoint will create a new jobtype.-
POST
/api/v1/jobtypes/ HTTP/1.1
¶ Request
POST /api/v1/jobtypes/ HTTP/1.1 Accept: application/json { "name": "TestJobType", "classname": "TestJobType", "description": "Jobtype for testing inserts and queries", "code": "\nfrom pyfarm.jobtypes.core.jobtype import " "JobType\n\nclass TestJobType(JobType):\n" " def get_command(self):\n" " return "/usr/bin/touch"\n\n" " def get_arguments(self):\n" " return [os.path.join(" "self.assignment_data["job"]["data"]["path"], " ""%04d" % self.assignment_data["tasks"]" "[0]["frame"])]\n" }
Response
HTTP/1.1 200 OK Content-Type: application/json { "id": 1, "batch_contiguous": true, "software_requirements": [], "version": 1, "max_batch": 1, "name": "TestJobType", "classname": "TestJobType", "description": "Jobtype for testing inserts and queries", "code": "\nfrom pyfarm.jobtypes.core.jobtype import " "JobType\n\nclass TestJobType(JobType):\n" " def get_command(self):\n" " return "/usr/bin/touch"\n\n" " def get_arguments(self):\n" " return [os.path.join(" "self.assignment_data["job"]["data"]["path"], " ""%04d" % self.assignment_data["tasks"]" "[0]["frame"])]\n" }
Statuscode 201: a new jobtype item was created Statuscode 400: there was something wrong with the request (such as invalid columns being included) Statuscode 409: a conflicting jobtype already exists -
-
-
class
pyfarm.master.api.jobtypes.
JobTypeSoftwareRequirementAPI
[source]¶ Bases:
flask.views.MethodView
-
delete
(jobtype_name, software)[source]¶ A
DELETE
to this endpoint will delete the requested software requirement from the specified jobtype, creating a new version of the jobtype in the process-
DELETE
/api/v1/jobtypes/[<str:name>|<int:id>]/software_requirements/<int:id> HTTP/1.1
¶ Request
DELETE /api/v1/jobtypes/TestJobType/software_requirements/1 HTTP/1.1 Accept: application/json
Response
HTTP/1.1 204 NO CONTENT
Statuscode 204: the software requirement was deleted or didn’t exist -
-
get
(jobtype_name, software)[source]¶ A
GET
to this endpoint will return the specified software requirement from the newest version of the requested jobtype.-
GET
/api/v1/jobtypes/[<str:name>|<int:id>]/software_requirements/<int:id> HTTP/1.1
¶ Request
GET /api/v1/jobtypes/TestJobType/software_requirements/1 HTTP/1.1 Accept: application/json
Response
HTTP/1.1 200 OK Content-Type: application/json { "software": { "software": "/bin/touch", "id": 1 }, "max_version": null, "min_version": { "version": "8.21", "id": 1 }, "jobtype_version": { "version": 7, "jobtype": "TestJobType" } }
Statuscode 200: no error Statuscode 404: jobtype or software requirement not found -
-
methods
= ['DELETE', 'GET']¶
-
-
class
pyfarm.master.api.jobtypes.
JobTypeSoftwareRequirementsIndexAPI
[source]¶ Bases:
flask.views.MethodView
-
get
(jobtype_name, version=None)[source]¶ A
GET
to this endpoint will return a list of all the software requirements of the specified jobtype-
GET
/api/v1/jobtypes/[<str:name>|<int:id>]/software_requirements/ HTTP/1.1
¶ Request
GET /api/v1/jobtypes/TestJobType/software_requirements/ HTTP/1.1 Accept: application/json
Response
HTTP/1.1 200 OK Content-Type: application/json [ { "software": { "software": "/bin/touch", "id": 1 }, "max_version": null, "min_version": { "version": "8.21", "id": 1 }, "jobtype_version": { "version": 7, "jobtype": "TestJobType" } } ]
Statuscode 200: no error Statuscode 404: jobtype or version not found -
-
methods
= ['GET', 'POST']¶
-
post
(jobtype_name, version=None)[source]¶ A
POST
to this endpoint will create a new software_requirement for the specified jobtype. This will transparently create a new jobtype version-
POST
/api/v1/jobtypes/[<str:name>|<int:id>]/software_requirements/ HTTP/1.1
¶ Request
POST /api/v1/jobtypes/TestJobType/software_requirements/ HTTP/1.1 Accept: application/json { "software": "blender", "min_version": "2.69" }
Response
HTTP/1.1 200 OK Content-Type: application/json { "jobtype_version": { "id": 8, "jobtype": "TestJobType", "version": 7 }, "max_version": null, "min_version": { "id": 2, "version": "1.69" }, "software": { "id": 2, "software": "blender" } }
Statuscode 201: a new software requirement was created Statuscode 400: there was something wrong with the request (such as invalid columns being included) Statuscode 405: you tried calling this method on a specific version Statuscode 409: a conflicting software requirement already exists -
-
-
class
pyfarm.master.api.jobtypes.
JobTypeVersionsIndexAPI
[source]¶ Bases:
flask.views.MethodView
-
get
(jobtype_name)[source]¶ A
GET
to this endpoint will return a sorted list of of all known versions of the specified jobtype.-
GET
/api/v1/jobtypes/[<str:name>|<int:id>]/versions/ HTTP/1.1
¶ Request
GET /api/v1/jobtypes/TestJobType/versions/ HTTP/1.1 Accept: application/json
Response
HTTP/1.1 200 OK Content-Type: application/json [1, 2]
Statuscode 200: no error Statuscode 404: jobtype not found -
-
methods
= ['GET']¶
-
-
class
pyfarm.master.api.jobtypes.
SingleJobTypeAPI
[source]¶ Bases:
flask.views.MethodView
-
delete
(jobtype_name)[source]¶ A
DELETE
to this endpoint will delete the requested jobtype-
DELETE
/api/v1/jobtypes/[<str:name>|<int:id>] HTTP/1.1
¶ Request
DELETE /api/v1/jobtypes/TestJobType HTTP/1.1 Accept: application/json
Response
HTTP/1.1 204 NO CONTENT
Statuscode 204: the jobtype was deleted or didn’t exist -
-
get
(jobtype_name)[source]¶ A
GET
to this endpoint will return the most recent version of the referenced jobtype, by name or id.-
GET
/api/v1/jobtypes/<str:tagname> HTTP/1.1
¶ Request
GET /api/v1/jobtypes/TestJobType HTTP/1.1 Accept: application/json
Response
HTTP/1.1 200 OK Content-Type: application/json { "batch_contiguous": true, "classname": null, "code": "\nfrom pyfarm.jobtypes.core.jobtype import " "JobType\n\nclass TestJobType(JobType):\n" " def get_command(self):\n" " return "/usr/bin/touch"\n\n" " def get_arguments(self):\n" " return [os.path.join(" "self.assignment_data["job"]["data"]["path"], " ""%04d" % self.assignment_data["tasks"]" "[0]["frame"])]\n", "id": 1, "version": 1, "max_batch": 1, "name": "TestJobType", "software_requirements": [ { "max_version": null, "max_version_id": null, "min_version": "8.21", "min_version_id": 1, "software": "/bin/touch", "software_id": 1 } ] }
Statuscode 200: no error Statuscode 404: jobtype or version not found -
-
methods
= ['DELETE', 'GET', 'PUT']¶
-
put
(jobtype_name)[source]¶ A
PUT
to this endpoint will create a new jobtype under the given URI. If a jobtype already exists under that URI, a new version will be created with the given data.You should only call this by id for updating an existing jobtype or if you have a reserved jobtype id. There is currently no way to reserve a jobtype id.
-
PUT
/api/v1/jobtypes/[<str:name>|<int:id>] HTTP/1.1
¶ Request
PUT /api/v1/jobtypes/TestJobType HTTP/1.1 Accept: application/json { "name": "TestJobType", "description": "Jobtype for testing inserts and queries", "code": "\nfrom pyfarm.jobtypes.core.jobtype import " "JobType\n\nclass TestJobType(JobType):\n" " def get_command(self):\n" " return "/usr/bin/touch"\n\n" " def get_arguments(self):\n" " return [os.path.join(" "self.assignment_data["job"]["data"]["path"], " ""%04d" % self.assignment_data["tasks"]" "[0]["frame"])]\n" }
Response
HTTP/1.1 201 CREATED Content-Type: application/json { "batch_contiguous": true, "classname": null, "code": "\nfrom pyfarm.jobtypes.core.jobtype import " "JobType\n\nclass TestJobType(JobType):\n" " def get_command(self):\n" " return "/usr/bin/touch"\n\n" " def get_arguments(self):\n" " return [os.path.join(" "self.assignment_data["job"]["data"]["path"], " ""%04d" % self.assignment_data["tasks"]" "[0]["frame"])]\n", "id": 1, "max_batch": 1, "name": "TestJobType", "description": "Jobtype for testing inserts and queries", "software_requirements": [] }
Statuscode 201: a new jobtype was created Statuscode 400: there was something wrong with the request (such as invalid columns being included) -
-
-
class
pyfarm.master.api.jobtypes.
VersionedJobTypeAPI
[source]¶ Bases:
flask.views.MethodView
-
delete
(jobtype_name, version)[source]¶ A
DELETE
to this endpoint will delete the requested version of the specified jobtype.-
DELETE
/api/v1/jobtypes/[<str:name>|<int:id>]/versions/<int:version> HTTP/1.1
¶ Request
DELETE /api/v1/jobtypes/TestJobType/versions/1 HTTP/1.1 Accept: application/json
Response
HTTP/1.1 204 NO CONTENT
Statuscode 204: the version was deleted or didn’t exist -
-
get
(jobtype_name, version)[source]¶ A
GET
to this endpoint will return the specified version of the referenced jobtype, by name or id.-
GET
/api/v1/jobtypes/[<str:name>|<int:id>]/versions/<int:version> HTTP/1.1
¶ Request
GET /api/v1/jobtypes/TestJobType/versions/1 HTTP/1.1 Accept: application/json
Response
HTTP/1.1 200 OK Content-Type: application/json { "batch_contiguous": true, "classname": null, "name": "TestJobType", "code": "\nfrom pyfarm.jobtypes.core.jobtype import " "JobType\n\nclass TestJobType(JobType):\n" " def get_command(self):\n" " return "/usr/bin/touch"\n\n" " def get_arguments(self):\n" " return [os.path.join(" "self.assignment_data["job"]["data"]["path"], " ""%04d" % self.assignment_data["tasks"]" "[0]["frame"])]\n", "id": 1, "version": 1, "max_batch": 1, "software_requirements": [ { "max_version": null, "max_version_id": null, "min_version": "8.21", "min_version_id": 1, "software": "/bin/touch", "software_id": 1 } ] }
Statuscode 200: no error Statuscode 404: jobtype or version not found -
-
methods
= ['DELETE', 'GET']¶
-
-
pyfarm.master.api.jobtypes.
parse_requirements
(requirements)[source]¶ Takes a list dicts specifying a software and optional min- and max-versions and returns a list of
JobRequirement
objects.Raises TypeError if the input was not as expected or ObjectNotFound if a referenced software of or version was not found.
Parameters: requirements (list) – A list of of dicts specifying a software and optionally min_version and/or max_version.
Raises: - TypeError – Raised if
requirements
is not a list or if an entry inrequirements
is not a dictionary. - ValueError – Raised if there’s a problem with the content of at least one of the requirement dictionaries.
- ObjectNotFound – Raised if the referenced software or version was not found
- TypeError – Raised if
-
pyfarm.master.api.jobtypes.
schema
()[source]¶ Returns the basic schema of
JobType
-
GET
/api/v1/jobtypes/schema HTTP/1.1
¶ Request
GET /api/v1/jobtypes/schema HTTP/1.1 Accept: application/json
Response
HTTP/1.1 200 OK Content-Type: application/json { "batch_contiguous": "BOOLEAN", "classname": "VARCHAR(64)", "code": "TEXT", "description": "TEXT", "id": "INTEGER", "version": "INTEGER", "max_batch": "INTEGER", "no_automatic_start_time": "INTEGER", "name": "VARCHAR(64)" }
Statuscode 200: no error -