From 602d921fac27707fd4727444cc2b4a4e4b74011b Mon Sep 17 00:00:00 2001 From: ialarmedalien Date: Fri, 21 Jan 2022 15:33:19 -0800 Subject: [PATCH] Removing old code relating to the defunct UJS --- .../static/kbase/js/util/timeFormat.js | 4 +- src/biokbase/narrative/clients.py | 21 +- src/biokbase/narrative/exception_util.py | 3 - src/biokbase/narrative/tests/test_clients.py | 32 + .../narrative/tests/test_exception_util.py | 39 +- src/biokbase/userandjobstate/__init__.py | 0 src/biokbase/userandjobstate/baseclient.py | 284 ------ src/biokbase/userandjobstate/client.py | 933 ------------------ 8 files changed, 60 insertions(+), 1256 deletions(-) create mode 100644 src/biokbase/narrative/tests/test_clients.py delete mode 100644 src/biokbase/userandjobstate/__init__.py delete mode 100644 src/biokbase/userandjobstate/baseclient.py delete mode 100644 src/biokbase/userandjobstate/client.py diff --git a/kbase-extension/static/kbase/js/util/timeFormat.js b/kbase-extension/static/kbase/js/util/timeFormat.js index f368df5f18..91679bcd29 100644 --- a/kbase-extension/static/kbase/js/util/timeFormat.js +++ b/kbase-extension/static/kbase/js/util/timeFormat.js @@ -95,8 +95,8 @@ define(['util/util'], (Utils) => { /** * @method reformatISOTimeString - * Parses the user_and_job_state timestamp and returns it as a user- - * readable string in the UTC time. + * Parses a timestamp and returns it as a user-readable string + * in the UTC time. * * This assumes that the timestamp string is in the following format: * diff --git a/src/biokbase/narrative/clients.py b/src/biokbase/narrative/clients.py index 521a435f0d..57b42f049a 100644 --- a/src/biokbase/narrative/clients.py +++ b/src/biokbase/narrative/clients.py @@ -1,6 +1,5 @@ from biokbase.workspace.client import Workspace from biokbase.narrative_method_store.client import NarrativeMethodStore -from biokbase.userandjobstate.client import UserAndJobState from biokbase.catalog.Client import Catalog from biokbase.service.Client import Client as ServiceClient from biokbase.execution_engine2.execution_engine2Client import execution_engine2 @@ -19,21 +18,23 @@ def reset(): def __init_client(client_name, token=None): if client_name == "workspace": c = Workspace(URLS.workspace, token=token) - elif ( - client_name == "execution_engine2" - or client_name == "execution_engine" - or client_name == "job_service" - ): + elif client_name == "execution_engine2": c = execution_engine2(URLS.execution_engine2, token=token) elif client_name == "narrative_method_store": c = NarrativeMethodStore(URLS.narrative_method_store, token=token) - elif client_name == "service" or client_name == "service_wizard": + elif client_name == "service": c = ServiceClient(URLS.service_wizard, use_url_lookup=True, token=token) elif client_name == "catalog": c = Catalog(URLS.catalog, token=token) - elif client_name == "user_and_job_state": - c = UserAndJobState(URLS.user_and_job_state, token=token) else: - raise ValueError('Unknown client name "%s"' % client_name) + raise ValueError( + 'Unknown client name "%s"\n' % client_name + + "The following client names are recognised:\n" + + 'Catalog: "catalog"\n' + + 'Execution Engine 2: "execution_engine2"\n' + + 'NMS: "narrative_method_store"\n' + + 'Service Wizard: "service"\n' + + 'Workspace: "workspace"' + ) return c diff --git a/src/biokbase/narrative/exception_util.py b/src/biokbase/narrative/exception_util.py index 6bec26d01c..1a5ab14314 100644 --- a/src/biokbase/narrative/exception_util.py +++ b/src/biokbase/narrative/exception_util.py @@ -1,6 +1,5 @@ from requests.exceptions import HTTPError from biokbase.execution_engine2.baseclient import ServerError as EEServerError -from biokbase.userandjobstate.baseclient import ServerError as UJSServerError class JobRequestException(ValueError): @@ -48,8 +47,6 @@ def transform_job_exception(e, error=None): """ if isinstance(e, EEServerError): return NarrativeException(e.code, e.message, e.name, "ee2", error) - elif isinstance(e, UJSServerError): - return NarrativeException(e.code, e.message, e.name, "ujs", error) elif isinstance(e, HTTPError): code = e.response.status_code if code == 404 or code == 502 or code == 503: diff --git a/src/biokbase/narrative/tests/test_clients.py b/src/biokbase/narrative/tests/test_clients.py new file mode 100644 index 0000000000..ff2e60e503 --- /dev/null +++ b/src/biokbase/narrative/tests/test_clients.py @@ -0,0 +1,32 @@ +import unittest +import biokbase.narrative.clients as clients + +from biokbase.workspace.client import Workspace as WS_Client +from biokbase.narrative_method_store.client import NarrativeMethodStore as NMS_Client +from biokbase.catalog.Client import Catalog as Catalog_Client +from biokbase.service.Client import Client as Service_Client +from biokbase.execution_engine2.execution_engine2Client import ( + execution_engine2 as EE2_Client, +) + + +class ClientsTestCase(unittest.TestCase): + def test_valid_clients(self): + name_to_type = { + "workspace": WS_Client, + "execution_engine2": EE2_Client, + "narrative_method_store": NMS_Client, + "service": Service_Client, + "catalog": Catalog_Client, + } + + for client_name, client_type in name_to_type.items(): + client = clients.get(client_name) + self.assertIsInstance(client, client_type) + + def test_invalid_clients(self): + invalid_names = ["service_wizard", "ee2", "ws"] + + for name in invalid_names: + with self.assertRaisesRegex(ValueError, "Unknown client name"): + clients.get(name) diff --git a/src/biokbase/narrative/tests/test_exception_util.py b/src/biokbase/narrative/tests/test_exception_util.py index f22ec6278d..24d7420774 100644 --- a/src/biokbase/narrative/tests/test_exception_util.py +++ b/src/biokbase/narrative/tests/test_exception_util.py @@ -1,18 +1,21 @@ import unittest from biokbase.narrative.exception_util import ( - NarrativeException, transform_job_exception, ) from biokbase.execution_engine2.baseclient import ServerError as EEServerError -from biokbase.userandjobstate.baseclient import ServerError as UJSServerError from requests.exceptions import HTTPError import requests +ERROR_MSG = "some error message" + +HTTP_ERROR = "HTTPError" +HTTP_ERROR_MSG = "http error message" + class ExceptionUtilTestCase(unittest.TestCase): def test_transform_ee2_err(self): code = 1000 - message = "some error message" + message = ERROR_MSG name = "EEError" ee2_err = EEServerError(name, code, message) nar_err = transform_job_exception(ee2_err) @@ -24,7 +27,7 @@ def test_transform_ee2_err(self): def test_transform_ee2_err__with_error(self): code = 1000 - message = "some error message" + message = ERROR_MSG name = "EEError" error = "Unable to perform some request" ee2_err = EEServerError(name, code, message) @@ -35,26 +38,14 @@ def test_transform_ee2_err__with_error(self): self.assertEqual(nar_err.source, "ee2") self.assertEqual(nar_err.error, error) - def test_transform_ujs_err(self): - code = 1000 - message = "some error message" - name = "UJSError" - ujs_err = UJSServerError(name, code, message) - nar_err = transform_job_exception(ujs_err) - self.assertEqual(nar_err.code, code) - self.assertEqual(nar_err.message, message) - self.assertEqual(nar_err.name, name) - self.assertEqual(nar_err.source, "ujs") - self.assertIsNone(nar_err.error) - def test_transform_http_err_unavailable(self): codes = [404, 502, 503] message = "A KBase service is currently unavailable." - name = "HTTPError" + name = HTTP_ERROR for c in codes: res = requests.Response() res.status_code = c - err = HTTPError("http error", response=res) + err = HTTPError(HTTP_ERROR_MSG, response=res) nar_err = transform_job_exception(err) self.assertEqual(nar_err.code, c) self.assertEqual(nar_err.message, message) @@ -65,11 +56,11 @@ def test_transform_http_err_unavailable(self): def test_transform_http_err_timeout(self): codes = [504, 598, 599] message = "There was a temporary network connection error." - name = "HTTPError" + name = HTTP_ERROR for c in codes: res = requests.Response() res.status_code = c - err = HTTPError("http error", response=res) + err = HTTPError(HTTP_ERROR_MSG, response=res) nar_err = transform_job_exception(err) self.assertEqual(nar_err.code, c) self.assertEqual(nar_err.message, message) @@ -80,10 +71,10 @@ def test_transform_http_err_timeout(self): def test_transform_http_err_internal(self): code = 500 message = "An internal error occurred in the KBase service." - name = "HTTPError" + name = HTTP_ERROR res = requests.Response() res.status_code = code - err = HTTPError("http error", response=res) + err = HTTPError(HTTP_ERROR_MSG, response=res) nar_err = transform_job_exception(err) self.assertEqual(nar_err.code, code) self.assertEqual(nar_err.message, message) @@ -94,10 +85,10 @@ def test_transform_http_err_internal(self): def test_transform_http_err_unknown(self): code = 666 message = "An untracked error occurred." - name = "HTTPError" + name = HTTP_ERROR res = requests.Response() res.status_code = code - err = HTTPError("http error", response=res) + err = HTTPError(HTTP_ERROR_MSG, response=res) nar_err = transform_job_exception(err) self.assertEqual(nar_err.code, code) self.assertEqual(nar_err.message, message) diff --git a/src/biokbase/userandjobstate/__init__.py b/src/biokbase/userandjobstate/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/biokbase/userandjobstate/baseclient.py b/src/biokbase/userandjobstate/baseclient.py deleted file mode 100644 index bf1548f572..0000000000 --- a/src/biokbase/userandjobstate/baseclient.py +++ /dev/null @@ -1,284 +0,0 @@ -############################################################ -# -# Autogenerated by the KBase type compiler - -# any changes made here will be overwritten -# -############################################################ - -import json as _json -import requests as _requests -import random as _random -import os as _os - -try: - from configparser import ConfigParser as _ConfigParser # py 3 -except ImportError: - from ConfigParser import ConfigParser as _ConfigParser # py 2 - -try: - from urllib.parse import urlparse as _urlparse # py3 -except ImportError: - from urlparse import urlparse as _urlparse # py2 -import time - -_CT = "content-type" -_AJ = "application/json" -_URL_SCHEME = frozenset(["http", "https"]) - - -def _get_token(user_id, password, auth_svc): - # This is bandaid helper function until we get a full - # KBase python auth client released - # note that currently globus usernames, and therefore kbase usernames, - # cannot contain non-ascii characters. In python 2, quote doesn't handle - # unicode, so if this changes this client will need to change. - body = ( - "user_id=" - + _requests.utils.quote(user_id) - + "&password=" - + _requests.utils.quote(password) - + "&fields=token" - ) - ret = _requests.post(auth_svc, data=body, allow_redirects=True) - status = ret.status_code - if status >= 200 and status <= 299: - tok = _json.loads(ret.text) - elif status == 403: - raise Exception( - "Authentication failed: Bad user_id/password " - + "combination for user %s" % (user_id) - ) - else: - raise Exception(ret.text) - return tok["token"] - - -def _read_inifile( - file=_os.environ.get( # @ReservedAssignment - "KB_DEPLOYMENT_CONFIG", _os.environ["HOME"] + "/.kbase_config" - ) -): - # Another bandaid to read in the ~/.kbase_config file if one is present - authdata = None - if _os.path.exists(file): - try: - config = _ConfigParser() - config.read(file) - # strip down whatever we read to only what is legit - authdata = { - x: config.get("authentication", x) - if config.has_option("authentication", x) - else None - for x in ( - "user_id", - "token", - "client_secret", - "keyfile", - "keyfile_passphrase", - "password", - ) - } - except Exception as e: - print("Error while reading INI file {}: {}".format(file, e)) - return authdata - - -class ServerError(Exception): - def __init__(self, name, code, message, data=None, error=None): - super(Exception, self).__init__(message) - self.name = name - self.code = code - self.message = "" if message is None else message - self.data = data or error or "" - # data = JSON RPC 2.0, error = 1.1 - - def __str__(self): - return ( - self.name + ": " + str(self.code) + ". " + self.message + "\n" + self.data - ) - - -class _JSONObjectEncoder(_json.JSONEncoder): - def default(self, obj): - if isinstance(obj, set): - return list(obj) - if isinstance(obj, frozenset): - return list(obj) - return _json.JSONEncoder.default(self, obj) - - -class BaseClient(object): - """ - The KBase base client. - Required initialization arguments (positional): - url - the url of the the service to contact: - For SDK methods: either the url of the callback service or the - Narrative Job Service Wrapper. - For SDK dynamic services: the url of the Service Wizard. - For other services: the url of the service. - Optional arguments (keywords in positional order): - timeout - methods will fail if they take longer than this value in seconds. - Default 1800. - user_id - a KBase user name. - password - the password corresponding to the user name. - token - a KBase authentication token. - ignore_authrc - if True, don't read auth configuration from - ~/.kbase_config. - trust_all_ssl_certificates - set to True to trust self-signed certificates. - If you don't understand the implications, leave as the default, False. - auth_svc - the url of the KBase authorization service. - lookup_url - set to true when contacting KBase dynamic services. - async_job_check_time_ms - the wait time between checking job state for - asynchronous jobs run with the run_job method. - """ - - def __init__( - self, - url=None, - timeout=30 * 60, - user_id=None, - password=None, - token=None, - ignore_authrc=False, - trust_all_ssl_certificates=False, - auth_svc="https://kbase.us/services/authorization/Sessions/Login", - lookup_url=False, - async_job_check_time_ms=5000, - ): - if url is None: - raise ValueError("A url is required") - scheme, _, _, _, _, _ = _urlparse(url) - if scheme not in _URL_SCHEME: - raise ValueError(url + " isn't a valid http url") - self.url = url - self.timeout = int(timeout) - self._headers = dict() - self.trust_all_ssl_certificates = trust_all_ssl_certificates - self.lookup_url = lookup_url - self.async_job_check_time = async_job_check_time_ms / 1000.0 - # token overrides user_id and password - if token is not None: - self._headers["AUTHORIZATION"] = token - elif user_id is not None and password is not None: - self._headers["AUTHORIZATION"] = _get_token(user_id, password, auth_svc) - elif "KB_AUTH_TOKEN" in _os.environ: - self._headers["AUTHORIZATION"] = _os.environ.get("KB_AUTH_TOKEN") - elif not ignore_authrc: - authdata = _read_inifile() - if authdata is not None: - if authdata.get("token") is not None: - self._headers["AUTHORIZATION"] = authdata["token"] - elif ( - authdata.get("user_id") is not None - and authdata.get("password") is not None - ): - self._headers["AUTHORIZATION"] = _get_token( - authdata["user_id"], authdata["password"], auth_svc - ) - if self.timeout < 1: - raise ValueError("Timeout value must be at least 1 second") - - def _call(self, url, method, params, context=None): - arg_hash = { - "method": method, - "params": params, - "version": "1.1", - "id": str(_random.random())[2:], - } - if context: - if not isinstance(context, dict): - raise ValueError("context is not type dict as required.") - arg_hash["context"] = context - - body = _json.dumps(arg_hash, cls=_JSONObjectEncoder) - ret = _requests.post( - url, - data=body, - headers=self._headers, - timeout=self.timeout, - verify=not self.trust_all_ssl_certificates, - ) - ret.encoding = "utf-8" - if ret.status_code == 500: - if ret.headers.get(_CT) == _AJ: - err = ret.json() - if "error" in err: - raise ServerError(**err["error"]) - else: - raise ServerError("Unknown", 0, ret.text) - else: - raise ServerError("Unknown", 0, ret.text) - if not ret.ok: - ret.raise_for_status() - resp = ret.json() - if "result" not in resp: - raise ServerError("Unknown", 0, "An unknown server error occurred") - if not resp["result"]: - return - if len(resp["result"]) == 1: - return resp["result"][0] - return resp["result"] - - def _get_service_url(self, service_method, service_version): - if not self.lookup_url: - return self.url - service, _ = service_method.split(".") - service_status_ret = self._call( - self.url, - "ServiceWizard.get_service_status", - [{"module_name": service, "version": service_version}], - ) - return service_status_ret["url"] - - def _set_up_context(self, service_ver=None, context=None): - if service_ver: - if not context: - context = {} - context["service_ver"] = service_ver - return context - - def _check_job(self, service, job_id): - return self._call(self.url, service + "._check_job", [job_id]) - - def _submit_job(self, service_method, args, service_ver=None, context=None): - context = self._set_up_context(service_ver, context) - mod, meth = service_method.split(".") - return self._call(self.url, mod + "._" + meth + "_submit", args, context) - - def run_job(self, service_method, args, service_ver=None, context=None): - """ - Run a SDK method asynchronously. - Required arguments: - service_method - the service and method to run, e.g. myserv.mymeth. - args - a list of arguments to the method. - Optional arguments: - service_ver - the version of the service to run, e.g. a git hash - or dev/beta/release. - context - the rpc context dict. - """ - mod, _ = service_method.split(".") - job_id = self._submit_job(service_method, args, service_ver, context) - while True: - time.sleep(self.async_job_check_time) - job_state = self._check_job(mod, job_id) - if job_state["finished"]: - if not job_state["result"]: - return - if len(job_state["result"]) == 1: - return job_state["result"][0] - return job_state["result"] - - def call_method(self, service_method, args, service_ver=None, context=None): - """ - Call a standard or dynamic service synchronously. - Required arguments: - service_method - the service and method to run, e.g. myserv.mymeth. - args - a list of arguments to the method. - Optional arguments: - service_ver - the version of the service to run, e.g. a git hash - or dev/beta/release. - context - the rpc context dict. - """ - url = self._get_service_url(service_method, service_ver) - context = self._set_up_context(service_ver, context) - return self._call(url, service_method, args, context) diff --git a/src/biokbase/userandjobstate/client.py b/src/biokbase/userandjobstate/client.py deleted file mode 100644 index 37416709ca..0000000000 --- a/src/biokbase/userandjobstate/client.py +++ /dev/null @@ -1,933 +0,0 @@ -############################################################ -# -# Autogenerated by the KBase type compiler - -# any changes made here will be overwritten -# -############################################################ - -# the following is a hack to get the baseclient to import whether we're in a -# package or not. This makes pep8 unhappy hence the annotations. -try: - # baseclient and this client are in a package - from .baseclient import BaseClient as _BaseClient # @UnusedImport -except BaseException: - # no they aren't - from baseclient import BaseClient as _BaseClient # @Reimport - - -class UserAndJobState(object): - def __init__( - self, - url=None, - timeout=30 * 60, - user_id=None, - password=None, - token=None, - ignore_authrc=False, - trust_all_ssl_certificates=False, - auth_svc="https://kbase.us/services/authorization/Sessions/Login", - ): - if url is None: - url = "https://kbase.us/services/userandjobstate/" - self._service_ver = None - self._client = _BaseClient( - url, - timeout=timeout, - user_id=user_id, - password=password, - token=token, - ignore_authrc=ignore_authrc, - trust_all_ssl_certificates=trust_all_ssl_certificates, - auth_svc=auth_svc, - ) - - def ver(self, context=None): - """ - Returns the version of the userandjobstate service. - :returns: instance of String - """ - return self._client.call_method( - "UserAndJobState.ver", [], self._service_ver, context - ) - - def set_state(self, service, key, value, context=None): - """ - Set the state of a key for a service without service authentication. - :param service: instance of type "service_name" (A service name. - Alphanumerics and the underscore are allowed.) - :param key: instance of String - :param value: instance of unspecified object - """ - return self._client.call_method( - "UserAndJobState.set_state", - [service, key, value], - self._service_ver, - context, - ) - - def set_state_auth(self, token, key, value, context=None): - """ - Set the state of a key for a service with service authentication. - :param token: instance of type "service_token" (A globus ID token - that validates that the service really is said service.) - :param key: instance of String - :param value: instance of unspecified object - """ - return self._client.call_method( - "UserAndJobState.set_state_auth", - [token, key, value], - self._service_ver, - context, - ) - - def get_state(self, service, key, auth, context=None): - """ - Get the state of a key for a service. - :param service: instance of type "service_name" (A service name. - Alphanumerics and the underscore are allowed.) - :param key: instance of String - :param auth: instance of type "authed" (Specifies whether results - returned should be from key/value pairs set with service - authentication (true) or without (false).) -> type "boolean" (A - boolean. 0 = false, other = true.) - :returns: instance of unspecified object - """ - return self._client.call_method( - "UserAndJobState.get_state", - [service, key, auth], - self._service_ver, - context, - ) - - def has_state(self, service, key, auth, context=None): - """ - Determine if a key exists for a service. - :param service: instance of type "service_name" (A service name. - Alphanumerics and the underscore are allowed.) - :param key: instance of String - :param auth: instance of type "authed" (Specifies whether results - returned should be from key/value pairs set with service - authentication (true) or without (false).) -> type "boolean" (A - boolean. 0 = false, other = true.) - :returns: instance of type "boolean" (A boolean. 0 = false, other = - true.) - """ - return self._client.call_method( - "UserAndJobState.has_state", - [service, key, auth], - self._service_ver, - context, - ) - - def get_has_state(self, service, key, auth, context=None): - """ - Get the state of a key for a service, and do not throw an error if the - key doesn't exist. If the key doesn't exist, has_key will be false - and the key value will be null. - :param service: instance of type "service_name" (A service name. - Alphanumerics and the underscore are allowed.) - :param key: instance of String - :param auth: instance of type "authed" (Specifies whether results - returned should be from key/value pairs set with service - authentication (true) or without (false).) -> type "boolean" (A - boolean. 0 = false, other = true.) - :returns: multiple set - (1) parameter "has_key" of type "boolean" (A - boolean. 0 = false, other = true.), (2) parameter "value" of - unspecified object - """ - return self._client.call_method( - "UserAndJobState.get_has_state", - [service, key, auth], - self._service_ver, - context, - ) - - def remove_state(self, service, key, context=None): - """ - Remove a key value pair without service authentication. - :param service: instance of type "service_name" (A service name. - Alphanumerics and the underscore are allowed.) - :param key: instance of String - """ - return self._client.call_method( - "UserAndJobState.remove_state", [service, key], self._service_ver, context - ) - - def remove_state_auth(self, token, key, context=None): - """ - Remove a key value pair with service authentication. - :param token: instance of type "service_token" (A globus ID token - that validates that the service really is said service.) - :param key: instance of String - """ - return self._client.call_method( - "UserAndJobState.remove_state_auth", - [token, key], - self._service_ver, - context, - ) - - def list_state(self, service, auth, context=None): - """ - List all keys. - :param service: instance of type "service_name" (A service name. - Alphanumerics and the underscore are allowed.) - :param auth: instance of type "authed" (Specifies whether results - returned should be from key/value pairs set with service - authentication (true) or without (false).) -> type "boolean" (A - boolean. 0 = false, other = true.) - :returns: instance of list of String - """ - return self._client.call_method( - "UserAndJobState.list_state", [service, auth], self._service_ver, context - ) - - def list_state_services(self, auth, context=None): - """ - List all state services. - :param auth: instance of type "authed" (Specifies whether results - returned should be from key/value pairs set with service - authentication (true) or without (false).) -> type "boolean" (A - boolean. 0 = false, other = true.) - :returns: instance of list of type "service_name" (A service name. - Alphanumerics and the underscore are allowed.) - """ - return self._client.call_method( - "UserAndJobState.list_state_services", [auth], self._service_ver, context - ) - - def create_job2(self, params, context=None): - """ - Create a new job status report. - :param params: instance of type "CreateJobParams" (Parameters for the - create_job2 method. Optional parameters: auth_strategy authstrat - - the authorization strategy to use for the job. Omit to use the - standard UJS authorization. If an authorization strategy is - supplied, in most cases an authparam must be supplied as well. - auth_param - a parameter for the authorization strategy. usermeta - meta - metadata for the job.) -> structure: parameter "authstrat" - of type "auth_strategy" (An authorization strategy to use for - jobs. Other than the DEFAULT strategy (ACLs local to the UJS and - managed by the UJS sharing functions), currently the only other - strategy is the 'kbaseworkspace' strategy, which consults the - workspace service for authorization information.), parameter - "authparam" of type "auth_param" (An authorization parameter. The - contents of this parameter differ by auth_strategy, but for the - workspace strategy it is the workspace id (an integer) as a - string.), parameter "meta" of type "usermeta" (User provided - metadata about a job. Arbitrary key-value pairs provided by the - user.) -> mapping from String to String - :returns: instance of type "job_id" (A job id.) - """ - return self._client.call_method( - "UserAndJobState.create_job2", [params], self._service_ver, context - ) - - def create_job(self, context=None): - """ - Create a new job status report. - @deprecated create_job2 - :returns: instance of type "job_id" (A job id.) - """ - return self._client.call_method( - "UserAndJobState.create_job", [], self._service_ver, context - ) - - def start_job(self, job, token, status, desc, progress, est_complete, context=None): - """ - Start a job and specify the job parameters. - :param job: instance of type "job_id" (A job id.) - :param token: instance of type "service_token" (A globus ID token - that validates that the service really is said service.) - :param status: instance of type "job_status" (A job status string - supplied by the reporting service. No more than 200 characters.) - :param desc: instance of type "job_description" (A job description - string supplied by the reporting service. No more than 1000 - characters.) - :param progress: instance of type "InitProgress" (Initialization - information for progress tracking. Currently 3 choices: - progress_type ptype - one of 'none', 'percent', or 'task' - max_progress max- required only for task based tracking. The total - number of tasks until the job is complete.) -> structure: - parameter "ptype" of type "progress_type" (The type of progress - that is being tracked. One of: 'none' - no numerical progress - tracking 'task' - Task based tracking, e.g. 3/24 'percent' - - percentage based tracking, e.g. 5/100%), parameter "max" of type - "max_progress" (The maximum possible progress of a job.) - :param est_complete: instance of type "timestamp" (A time in the - format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to - UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)) - """ - return self._client.call_method( - "UserAndJobState.start_job", - [job, token, status, desc, progress, est_complete], - self._service_ver, - context, - ) - - def create_and_start_job( - self, token, status, desc, progress, est_complete, context=None - ): - """ - Create and start a job. - :param token: instance of type "service_token" (A globus ID token - that validates that the service really is said service.) - :param status: instance of type "job_status" (A job status string - supplied by the reporting service. No more than 200 characters.) - :param desc: instance of type "job_description" (A job description - string supplied by the reporting service. No more than 1000 - characters.) - :param progress: instance of type "InitProgress" (Initialization - information for progress tracking. Currently 3 choices: - progress_type ptype - one of 'none', 'percent', or 'task' - max_progress max- required only for task based tracking. The total - number of tasks until the job is complete.) -> structure: - parameter "ptype" of type "progress_type" (The type of progress - that is being tracked. One of: 'none' - no numerical progress - tracking 'task' - Task based tracking, e.g. 3/24 'percent' - - percentage based tracking, e.g. 5/100%), parameter "max" of type - "max_progress" (The maximum possible progress of a job.) - :param est_complete: instance of type "timestamp" (A time in the - format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to - UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)) - :returns: instance of type "job_id" (A job id.) - """ - return self._client.call_method( - "UserAndJobState.create_and_start_job", - [token, status, desc, progress, est_complete], - self._service_ver, - context, - ) - - def update_job_progress(self, job, token, status, prog, est_complete, context=None): - """ - Update the status and progress for a job. - :param job: instance of type "job_id" (A job id.) - :param token: instance of type "service_token" (A globus ID token - that validates that the service really is said service.) - :param status: instance of type "job_status" (A job status string - supplied by the reporting service. No more than 200 characters.) - :param prog: instance of type "progress" (The amount of progress the - job has made since the last update. This will be summed to the - total progress so far.) - :param est_complete: instance of type "timestamp" (A time in the - format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to - UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)) - """ - return self._client.call_method( - "UserAndJobState.update_job_progress", - [job, token, status, prog, est_complete], - self._service_ver, - context, - ) - - def update_job(self, job, token, status, est_complete, context=None): - """ - Update the status for a job. - :param job: instance of type "job_id" (A job id.) - :param token: instance of type "service_token" (A globus ID token - that validates that the service really is said service.) - :param status: instance of type "job_status" (A job status string - supplied by the reporting service. No more than 200 characters.) - :param est_complete: instance of type "timestamp" (A time in the - format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to - UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)) - """ - return self._client.call_method( - "UserAndJobState.update_job", - [job, token, status, est_complete], - self._service_ver, - context, - ) - - def get_job_description(self, job, context=None): - """ - Get the description of a job. - :param job: instance of type "job_id" (A job id.) - :returns: multiple set - (1) parameter "service" of type - "service_name" (A service name. Alphanumerics and the underscore - are allowed.), (2) parameter "ptype" of type "progress_type" (The - type of progress that is being tracked. One of: 'none' - no - numerical progress tracking 'task' - Task based tracking, e.g. - 3/24 'percent' - percentage based tracking, e.g. 5/100%), (3) - parameter "max" of type "max_progress" (The maximum possible - progress of a job.), (4) parameter "desc" of type - "job_description" (A job description string supplied by the - reporting service. No more than 1000 characters.), (5) parameter - "started" of type "timestamp" (A time in the format - YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to UTC in - the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)) - """ - return self._client.call_method( - "UserAndJobState.get_job_description", [job], self._service_ver, context - ) - - def get_job_status(self, job, context=None): - """ - Get the status of a job. - :param job: instance of type "job_id" (A job id.) - :returns: multiple set - (1) parameter "last_update" of type - "timestamp" (A time in the format YYYY-MM-DDThh:mm:ssZ, where Z is - the difference in time to UTC in the format +/-HHMM, eg: - 2012-12-17T23:24:06-0500 (EST time) 2013-04-03T08:56:32+0000 (UTC - time)), (2) parameter "stage" of type "job_stage" (A string that - describes the stage of processing of the job. One of 'created', - 'started', 'completed', 'canceled' or 'error'.), (3) parameter - "status" of type "job_status" (A job status string supplied by the - reporting service. No more than 200 characters.), (4) parameter - "progress" of type "total_progress" (The total progress of a - job.), (5) parameter "est_complete" of type "timestamp" (A time in - the format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time - to UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST - time) 2013-04-03T08:56:32+0000 (UTC time)), (6) parameter - "complete" of type "boolean" (A boolean. 0 = false, other = - true.), (7) parameter "error" of type "boolean" (A boolean. 0 = - false, other = true.) - """ - return self._client.call_method( - "UserAndJobState.get_job_status", [job], self._service_ver, context - ) - - def complete_job(self, job, token, status, error, res, context=None): - """ - Complete the job. After the job is completed, total_progress always - equals max_progress. If detailed_err is anything other than null, - the job is considered to have errored out. - :param job: instance of type "job_id" (A job id.) - :param token: instance of type "service_token" (A globus ID token - that validates that the service really is said service.) - :param status: instance of type "job_status" (A job status string - supplied by the reporting service. No more than 200 characters.) - :param error: instance of type "detailed_err" (Detailed information - about a job error, such as a stacktrace, that will not fit in the - job_status. No more than 100K characters.) - :param res: instance of type "Results" (A pointer to job results. All - arguments are optional. Applications should use the default shock - and workspace urls if omitted. list shocknodes - the - shocknode(s) where the results can be found. No more than 1000 - characters. string shockurl - the url of the shock service where - the data was saved. No more than 1000 characters. list - workspaceids - the workspace ids where the results can be found. - No more than 1000 characters. string workspaceurl - the url of the - workspace service where the data was saved. No more than 1000 - characters. list - a set of job results. This format - allows for specifying results at multiple server locations and - providing a free text description of the result.) -> structure: - parameter "shocknodes" of list of String, parameter "shockurl" of - String, parameter "workspaceids" of list of String, parameter - "workspaceurl" of String, parameter "results" of list of type - "Result" (A place where the results of a job may be found. All - fields except description are required. string server_type - the - type of server storing the results. Typically either "Shock" or - "Workspace". No more than 100 characters. string url - the url of - the server. No more than 1000 characters. string id - the id of - the result in the server. Typically either a workspace id or a - shock node. No more than 1000 characters. string description - a - free text description of the result. No more than 1000 - characters.) -> structure: parameter "server_type" of String, - parameter "url" of String, parameter "id" of String, parameter - "description" of String - """ - return self._client.call_method( - "UserAndJobState.complete_job", - [job, token, status, error, res], - self._service_ver, - context, - ) - - def cancel_job(self, job, status, context=None): - """ - Cancel a job. - :param job: instance of type "job_id" (A job id.) - :param status: instance of type "job_status" (A job status string - supplied by the reporting service. No more than 200 characters.) - """ - return self._client.call_method( - "UserAndJobState.cancel_job", [job, status], self._service_ver, context - ) - - def get_results(self, job, context=None): - """ - Get the job results. - :param job: instance of type "job_id" (A job id.) - :returns: instance of type "Results" (A pointer to job results. All - arguments are optional. Applications should use the default shock - and workspace urls if omitted. list shocknodes - the - shocknode(s) where the results can be found. No more than 1000 - characters. string shockurl - the url of the shock service where - the data was saved. No more than 1000 characters. list - workspaceids - the workspace ids where the results can be found. - No more than 1000 characters. string workspaceurl - the url of the - workspace service where the data was saved. No more than 1000 - characters. list - a set of job results. This format - allows for specifying results at multiple server locations and - providing a free text description of the result.) -> structure: - parameter "shocknodes" of list of String, parameter "shockurl" of - String, parameter "workspaceids" of list of String, parameter - "workspaceurl" of String, parameter "results" of list of type - "Result" (A place where the results of a job may be found. All - fields except description are required. string server_type - the - type of server storing the results. Typically either "Shock" or - "Workspace". No more than 100 characters. string url - the url of - the server. No more than 1000 characters. string id - the id of - the result in the server. Typically either a workspace id or a - shock node. No more than 1000 characters. string description - a - free text description of the result. No more than 1000 - characters.) -> structure: parameter "server_type" of String, - parameter "url" of String, parameter "id" of String, parameter - "description" of String - """ - return self._client.call_method( - "UserAndJobState.get_results", [job], self._service_ver, context - ) - - def get_detailed_error(self, job, context=None): - """ - Get the detailed error message, if any - :param job: instance of type "job_id" (A job id.) - :returns: instance of type "detailed_err" (Detailed information about - a job error, such as a stacktrace, that will not fit in the - job_status. No more than 100K characters.) - """ - return self._client.call_method( - "UserAndJobState.get_detailed_error", [job], self._service_ver, context - ) - - def get_job_info2(self, job, context=None): - """ - Get information about a job. - :param job: instance of type "job_id" (A job id.) - :returns: instance of type "job_info2" (Information about a job.) -> - tuple of size 13: parameter "job" of type "job_id" (A job id.), - parameter "users" of type "user_info" (Who owns a job and who - canceled a job (null if not canceled).) -> tuple of size 2: - parameter "owner" of type "username" (Login name of a KBase user - account.), parameter "canceledby" of type "username" (Login name - of a KBase user account.), parameter "service" of type - "service_name" (A service name. Alphanumerics and the underscore - are allowed.), parameter "stage" of type "job_stage" (A string - that describes the stage of processing of the job. One of - 'created', 'started', 'completed', 'canceled' or 'error'.), - parameter "status" of type "job_status" (A job status string - supplied by the reporting service. No more than 200 characters.), - parameter "times" of type "time_info" (Job timing information.) -> - tuple of size 3: parameter "started" of type "timestamp" (A time - in the format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in - time to UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 - (EST time) 2013-04-03T08:56:32+0000 (UTC time)), parameter - "last_update" of type "timestamp" (A time in the format - YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to UTC in - the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)), parameter "est_complete" of - type "timestamp" (A time in the format YYYY-MM-DDThh:mm:ssZ, where - Z is the difference in time to UTC in the format +/-HHMM, eg: - 2012-12-17T23:24:06-0500 (EST time) 2013-04-03T08:56:32+0000 (UTC - time)), parameter "progress" of type "progress_info" (Job progress - information.) -> tuple of size 3: parameter "prog" of type - "total_progress" (The total progress of a job.), parameter "max" - of type "max_progress" (The maximum possible progress of a job.), - parameter "ptype" of type "progress_type" (The type of progress - that is being tracked. One of: 'none' - no numerical progress - tracking 'task' - Task based tracking, e.g. 3/24 'percent' - - percentage based tracking, e.g. 5/100%), parameter "complete" of - type "boolean" (A boolean. 0 = false, other = true.), parameter - "error" of type "boolean" (A boolean. 0 = false, other = true.), - parameter "auth" of type "auth_info" (Job authorization strategy - information.) -> tuple of size 2: parameter "strat" of type - "auth_strategy" (An authorization strategy to use for jobs. Other - than the DEFAULT strategy (ACLs local to the UJS and managed by - the UJS sharing functions), currently the only other strategy is - the 'kbaseworkspace' strategy, which consults the workspace - service for authorization information.), parameter "param" of type - "auth_param" (An authorization parameter. The contents of this - parameter differ by auth_strategy, but for the workspace strategy - it is the workspace id (an integer) as a string.), parameter - "meta" of type "usermeta" (User provided metadata about a job. - Arbitrary key-value pairs provided by the user.) -> mapping from - String to String, parameter "desc" of type "job_description" (A - job description string supplied by the reporting service. No more - than 1000 characters.), parameter "res" of type "Results" (A - pointer to job results. All arguments are optional. Applications - should use the default shock and workspace urls if omitted. - list shocknodes - the shocknode(s) where the results can - be found. No more than 1000 characters. string shockurl - the url - of the shock service where the data was saved. No more than 1000 - characters. list workspaceids - the workspace ids where - the results can be found. No more than 1000 characters. string - workspaceurl - the url of the workspace service where the data was - saved. No more than 1000 characters. list - a set of job - results. This format allows for specifying results at multiple - server locations and providing a free text description of the - result.) -> structure: parameter "shocknodes" of list of String, - parameter "shockurl" of String, parameter "workspaceids" of list - of String, parameter "workspaceurl" of String, parameter "results" - of list of type "Result" (A place where the results of a job may - be found. All fields except description are required. string - server_type - the type of server storing the results. Typically - either "Shock" or "Workspace". No more than 100 characters. string - url - the url of the server. No more than 1000 characters. string - id - the id of the result in the server. Typically either a - workspace id or a shock node. No more than 1000 characters. string - description - a free text description of the result. No more than - 1000 characters.) -> structure: parameter "server_type" of String, - parameter "url" of String, parameter "id" of String, parameter - "description" of String - """ - return self._client.call_method( - "UserAndJobState.get_job_info2", [job], self._service_ver, context - ) - - def get_job_info(self, job, context=None): - """ - Get information about a job. - @deprecated get_job_info2 - :param job: instance of type "job_id" (A job id.) - :returns: instance of type "job_info" (Information about a job. - @deprecated job_info2) -> tuple of size 14: parameter "job" of - type "job_id" (A job id.), parameter "service" of type - "service_name" (A service name. Alphanumerics and the underscore - are allowed.), parameter "stage" of type "job_stage" (A string - that describes the stage of processing of the job. One of - 'created', 'started', 'completed', 'canceled' or 'error'.), - parameter "started" of type "timestamp" (A time in the format - YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to UTC in - the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)), parameter "status" of type - "job_status" (A job status string supplied by the reporting - service. No more than 200 characters.), parameter "last_update" of - type "timestamp" (A time in the format YYYY-MM-DDThh:mm:ssZ, where - Z is the difference in time to UTC in the format +/-HHMM, eg: - 2012-12-17T23:24:06-0500 (EST time) 2013-04-03T08:56:32+0000 (UTC - time)), parameter "prog" of type "total_progress" (The total - progress of a job.), parameter "max" of type "max_progress" (The - maximum possible progress of a job.), parameter "ptype" of type - "progress_type" (The type of progress that is being tracked. One - of: 'none' - no numerical progress tracking 'task' - Task based - tracking, e.g. 3/24 'percent' - percentage based tracking, e.g. - 5/100%), parameter "est_complete" of type "timestamp" (A time in - the format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time - to UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST - time) 2013-04-03T08:56:32+0000 (UTC time)), parameter "complete" - of type "boolean" (A boolean. 0 = false, other = true.), parameter - "error" of type "boolean" (A boolean. 0 = false, other = true.), - parameter "desc" of type "job_description" (A job description - string supplied by the reporting service. No more than 1000 - characters.), parameter "res" of type "Results" (A pointer to job - results. All arguments are optional. Applications should use the - default shock and workspace urls if omitted. list - shocknodes - the shocknode(s) where the results can be found. No - more than 1000 characters. string shockurl - the url of the shock - service where the data was saved. No more than 1000 characters. - list workspaceids - the workspace ids where the results - can be found. No more than 1000 characters. string workspaceurl - - the url of the workspace service where the data was saved. No - more than 1000 characters. list - a set of job results. - This format allows for specifying results at multiple server - locations and providing a free text description of the result.) -> - structure: parameter "shocknodes" of list of String, parameter - "shockurl" of String, parameter "workspaceids" of list of String, - parameter "workspaceurl" of String, parameter "results" of list of - type "Result" (A place where the results of a job may be found. - All fields except description are required. string server_type - - the type of server storing the results. Typically either "Shock" - or "Workspace". No more than 100 characters. string url - the url - of the server. No more than 1000 characters. string id - the id of - the result in the server. Typically either a workspace id or a - shock node. No more than 1000 characters. string description - a - free text description of the result. No more than 1000 - characters.) -> structure: parameter "server_type" of String, - parameter "url" of String, parameter "id" of String, parameter - "description" of String - """ - return self._client.call_method( - "UserAndJobState.get_job_info", [job], self._service_ver, context - ) - - def list_jobs2(self, params, context=None): - """ - List jobs. - :param params: instance of type "ListJobsParams" (Input parameters - for the list_jobs2 method. Optional parameters: list - services - the services from which to list jobs. Omit to list jobs - from all services. job_filter filter - the filter to apply to the - set of jobs. auth_strategy authstrat - return jobs with the - specified authorization strategy. If this parameter is omitted, - jobs with the default strategy will be returned. list - authparams - only return jobs with one of the specified - authorization parameters. An authorization strategy must be - provided if authparams is specified. In most cases, at least one - authorization parameter must be supplied and there is an upper - limit to the number of paramters allowed. In the case of the - kbaseworkspace strategy, these limits are 1 and 10, respectively.) - -> structure: parameter "services" of list of type "service_name" - (A service name. Alphanumerics and the underscore are allowed.), - parameter "filter" of type "job_filter" (A string-based filter for - listing jobs. If the string contains: 'R' - running jobs are - returned. 'C' - completed jobs are returned. 'N' - canceled jobs - are returned. 'E' - jobs that errored out are returned. 'S' - - shared jobs are returned. The string can contain any combination - of these codes in any order. If the string contains none of the - codes or is null, all self-owned jobs are returned. If only the S - filter is present, all jobs are returned. The S filter is ignored - for jobs not using the default authorization strategy.), parameter - "authstrat" of type "auth_strategy" (An authorization strategy to - use for jobs. Other than the DEFAULT strategy (ACLs local to the - UJS and managed by the UJS sharing functions), currently the only - other strategy is the 'kbaseworkspace' strategy, which consults - the workspace service for authorization information.), parameter - "authparams" of list of type "auth_param" (An authorization - parameter. The contents of this parameter differ by auth_strategy, - but for the workspace strategy it is the workspace id (an integer) - as a string.) - :returns: instance of list of type "job_info2" (Information about a - job.) -> tuple of size 13: parameter "job" of type "job_id" (A job - id.), parameter "users" of type "user_info" (Who owns a job and - who canceled a job (null if not canceled).) -> tuple of size 2: - parameter "owner" of type "username" (Login name of a KBase user - account.), parameter "canceledby" of type "username" (Login name - of a KBase user account.), parameter "service" of type - "service_name" (A service name. Alphanumerics and the underscore - are allowed.), parameter "stage" of type "job_stage" (A string - that describes the stage of processing of the job. One of - 'created', 'started', 'completed', 'canceled' or 'error'.), - parameter "status" of type "job_status" (A job status string - supplied by the reporting service. No more than 200 characters.), - parameter "times" of type "time_info" (Job timing information.) -> - tuple of size 3: parameter "started" of type "timestamp" (A time - in the format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in - time to UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 - (EST time) 2013-04-03T08:56:32+0000 (UTC time)), parameter - "last_update" of type "timestamp" (A time in the format - YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to UTC in - the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)), parameter "est_complete" of - type "timestamp" (A time in the format YYYY-MM-DDThh:mm:ssZ, where - Z is the difference in time to UTC in the format +/-HHMM, eg: - 2012-12-17T23:24:06-0500 (EST time) 2013-04-03T08:56:32+0000 (UTC - time)), parameter "progress" of type "progress_info" (Job progress - information.) -> tuple of size 3: parameter "prog" of type - "total_progress" (The total progress of a job.), parameter "max" - of type "max_progress" (The maximum possible progress of a job.), - parameter "ptype" of type "progress_type" (The type of progress - that is being tracked. One of: 'none' - no numerical progress - tracking 'task' - Task based tracking, e.g. 3/24 'percent' - - percentage based tracking, e.g. 5/100%), parameter "complete" of - type "boolean" (A boolean. 0 = false, other = true.), parameter - "error" of type "boolean" (A boolean. 0 = false, other = true.), - parameter "auth" of type "auth_info" (Job authorization strategy - information.) -> tuple of size 2: parameter "strat" of type - "auth_strategy" (An authorization strategy to use for jobs. Other - than the DEFAULT strategy (ACLs local to the UJS and managed by - the UJS sharing functions), currently the only other strategy is - the 'kbaseworkspace' strategy, which consults the workspace - service for authorization information.), parameter "param" of type - "auth_param" (An authorization parameter. The contents of this - parameter differ by auth_strategy, but for the workspace strategy - it is the workspace id (an integer) as a string.), parameter - "meta" of type "usermeta" (User provided metadata about a job. - Arbitrary key-value pairs provided by the user.) -> mapping from - String to String, parameter "desc" of type "job_description" (A - job description string supplied by the reporting service. No more - than 1000 characters.), parameter "res" of type "Results" (A - pointer to job results. All arguments are optional. Applications - should use the default shock and workspace urls if omitted. - list shocknodes - the shocknode(s) where the results can - be found. No more than 1000 characters. string shockurl - the url - of the shock service where the data was saved. No more than 1000 - characters. list workspaceids - the workspace ids where - the results can be found. No more than 1000 characters. string - workspaceurl - the url of the workspace service where the data was - saved. No more than 1000 characters. list - a set of job - results. This format allows for specifying results at multiple - server locations and providing a free text description of the - result.) -> structure: parameter "shocknodes" of list of String, - parameter "shockurl" of String, parameter "workspaceids" of list - of String, parameter "workspaceurl" of String, parameter "results" - of list of type "Result" (A place where the results of a job may - be found. All fields except description are required. string - server_type - the type of server storing the results. Typically - either "Shock" or "Workspace". No more than 100 characters. string - url - the url of the server. No more than 1000 characters. string - id - the id of the result in the server. Typically either a - workspace id or a shock node. No more than 1000 characters. string - description - a free text description of the result. No more than - 1000 characters.) -> structure: parameter "server_type" of String, - parameter "url" of String, parameter "id" of String, parameter - "description" of String - """ - return self._client.call_method( - "UserAndJobState.list_jobs2", [params], self._service_ver, context - ) - - def list_jobs(self, services, filter, context=None): - """ - List jobs. Leave 'services' empty or null to list jobs from all - services. - @deprecated list_jobs2 - :param services: instance of list of type "service_name" (A service - name. Alphanumerics and the underscore are allowed.) - :param filter: instance of type "job_filter" (A string-based filter - for listing jobs. If the string contains: 'R' - running jobs are - returned. 'C' - completed jobs are returned. 'N' - canceled jobs - are returned. 'E' - jobs that errored out are returned. 'S' - - shared jobs are returned. The string can contain any combination - of these codes in any order. If the string contains none of the - codes or is null, all self-owned jobs are returned. If only the S - filter is present, all jobs are returned. The S filter is ignored - for jobs not using the default authorization strategy.) - :returns: instance of list of type "job_info" (Information about a - job. @deprecated job_info2) -> tuple of size 14: parameter "job" - of type "job_id" (A job id.), parameter "service" of type - "service_name" (A service name. Alphanumerics and the underscore - are allowed.), parameter "stage" of type "job_stage" (A string - that describes the stage of processing of the job. One of - 'created', 'started', 'completed', 'canceled' or 'error'.), - parameter "started" of type "timestamp" (A time in the format - YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time to UTC in - the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST time) - 2013-04-03T08:56:32+0000 (UTC time)), parameter "status" of type - "job_status" (A job status string supplied by the reporting - service. No more than 200 characters.), parameter "last_update" of - type "timestamp" (A time in the format YYYY-MM-DDThh:mm:ssZ, where - Z is the difference in time to UTC in the format +/-HHMM, eg: - 2012-12-17T23:24:06-0500 (EST time) 2013-04-03T08:56:32+0000 (UTC - time)), parameter "prog" of type "total_progress" (The total - progress of a job.), parameter "max" of type "max_progress" (The - maximum possible progress of a job.), parameter "ptype" of type - "progress_type" (The type of progress that is being tracked. One - of: 'none' - no numerical progress tracking 'task' - Task based - tracking, e.g. 3/24 'percent' - percentage based tracking, e.g. - 5/100%), parameter "est_complete" of type "timestamp" (A time in - the format YYYY-MM-DDThh:mm:ssZ, where Z is the difference in time - to UTC in the format +/-HHMM, eg: 2012-12-17T23:24:06-0500 (EST - time) 2013-04-03T08:56:32+0000 (UTC time)), parameter "complete" - of type "boolean" (A boolean. 0 = false, other = true.), parameter - "error" of type "boolean" (A boolean. 0 = false, other = true.), - parameter "desc" of type "job_description" (A job description - string supplied by the reporting service. No more than 1000 - characters.), parameter "res" of type "Results" (A pointer to job - results. All arguments are optional. Applications should use the - default shock and workspace urls if omitted. list - shocknodes - the shocknode(s) where the results can be found. No - more than 1000 characters. string shockurl - the url of the shock - service where the data was saved. No more than 1000 characters. - list workspaceids - the workspace ids where the results - can be found. No more than 1000 characters. string workspaceurl - - the url of the workspace service where the data was saved. No - more than 1000 characters. list - a set of job results. - This format allows for specifying results at multiple server - locations and providing a free text description of the result.) -> - structure: parameter "shocknodes" of list of String, parameter - "shockurl" of String, parameter "workspaceids" of list of String, - parameter "workspaceurl" of String, parameter "results" of list of - type "Result" (A place where the results of a job may be found. - All fields except description are required. string server_type - - the type of server storing the results. Typically either "Shock" - or "Workspace". No more than 100 characters. string url - the url - of the server. No more than 1000 characters. string id - the id of - the result in the server. Typically either a workspace id or a - shock node. No more than 1000 characters. string description - a - free text description of the result. No more than 1000 - characters.) -> structure: parameter "server_type" of String, - parameter "url" of String, parameter "id" of String, parameter - "description" of String - """ - return self._client.call_method( - "UserAndJobState.list_jobs", [services, filter], self._service_ver, context - ) - - def list_job_services(self, context=None): - """ - List all job services. Note that only services with jobs owned by the - user or shared with the user via the default auth strategy will be - listed. - :returns: instance of list of type "service_name" (A service name. - Alphanumerics and the underscore are allowed.) - """ - return self._client.call_method( - "UserAndJobState.list_job_services", [], self._service_ver, context - ) - - def share_job(self, job, users, context=None): - """ - Share a job. Sharing a job to the same user twice or with the job owner - has no effect. Attempting to share a job not using the default auth - strategy will fail. - :param job: instance of type "job_id" (A job id.) - :param users: instance of list of type "username" (Login name of a - KBase user account.) - """ - return self._client.call_method( - "UserAndJobState.share_job", [job, users], self._service_ver, context - ) - - def unshare_job(self, job, users, context=None): - """ - Stop sharing a job. Removing sharing from a user that the job is not - shared with or the job owner has no effect. Attemping to unshare a job - not using the default auth strategy will fail. - :param job: instance of type "job_id" (A job id.) - :param users: instance of list of type "username" (Login name of a - KBase user account.) - """ - return self._client.call_method( - "UserAndJobState.unshare_job", [job, users], self._service_ver, context - ) - - def get_job_owner(self, job, context=None): - """ - Get the owner of a job. - :param job: instance of type "job_id" (A job id.) - :returns: instance of type "username" (Login name of a KBase user - account.) - """ - return self._client.call_method( - "UserAndJobState.get_job_owner", [job], self._service_ver, context - ) - - def get_job_shared(self, job, context=None): - """ - Get the list of users with which a job is shared. Only the job owner - may access this method. Returns an empty list for jobs not using the - default auth strategy. - :param job: instance of type "job_id" (A job id.) - :returns: instance of list of type "username" (Login name of a KBase - user account.) - """ - return self._client.call_method( - "UserAndJobState.get_job_shared", [job], self._service_ver, context - ) - - def delete_job(self, job, context=None): - """ - Delete a job. Will fail if the job is not complete. Only the job owner - can delete a job. - :param job: instance of type "job_id" (A job id.) - """ - return self._client.call_method( - "UserAndJobState.delete_job", [job], self._service_ver, context - ) - - def force_delete_job(self, token, job, context=None): - """ - Force delete a job - will succeed unless the job has not been started. - In that case, the service must start the job and then delete it, since - a job is not "owned" by any service until it is started. Only the job - owner can delete a job. - :param token: instance of type "service_token" (A globus ID token - that validates that the service really is said service.) - :param job: instance of type "job_id" (A job id.) - """ - return self._client.call_method( - "UserAndJobState.force_delete_job", [token, job], self._service_ver, context - ) - - def status(self, context=None): - return self._client.call_method( - "UserAndJobState.status", [], self._service_ver, context - )