error package¶
Subpackages¶
- error.migrations package
- Submodules
- error.migrations.0001_initial module
- error.migrations.0002_auto_20151217_1319 module
- error.migrations.0003_error_is_builtin module
- error.migrations.0004_error_should_be_retried module
- error.migrations.0005_auto_20180621_2110 module
- error.migrations.0006_update_retried module
- Module contents
- error.test package
Submodules¶
error.apps module¶
The scale error application
error.exceptions module¶
Defines exceptions that can occur when interacting with jobs and job types
-
exception
error.exceptions.ScaleDatabaseError¶ Bases:
error.exceptions.ScaleErrorError class that wraps the Django DatabaseError
-
get_log_message()¶
-
-
exception
error.exceptions.ScaleError(exit_code, error_name, log_stacktrace=False, wrapped_ex=None)¶ Bases:
exceptions.ExceptionAbstract base class for exceptions that represent Scale errors. The exceptions contain exit code and error information.
-
get_log_message()¶ The log message to print out when the error occurs. This should be overridden by derived classes to provide detailed log messaging.
Returns: The log message Return type: string
-
log()¶ Logs the error message
-
-
exception
error.exceptions.ScaleIOError¶ Bases:
error.exceptions.ScaleErrorError class that wraps the Python IOError
-
get_log_message()¶
-
-
exception
error.exceptions.ScaleOperationalError¶ Bases:
error.exceptions.ScaleErrorError class that wraps the Django OperationalError
-
get_log_message()¶
-
-
error.exceptions.get_error_by_exception(wrapped_ex)¶ Returns the ScaleError that corresponds to the given wrapped exception class name, possibly None
Parameters: wrapped_ex (string) – The name of the wrapped exception class Returns: The error, possibly None Return type: error.exceptions.ScaleError
-
error.exceptions.get_error_by_exit_code(exit_code)¶ Returns the name of the error that corresponds to the given exit code, possibly None
Parameters: exit_code (int) – The exit code Returns: The error model, possibly None Return type: error.models.Error
-
error.exceptions.register_error(error)¶ Registers the given ScaleError
Parameters: error ( error.exceptions.ScaleError) – The ScaleError
error.handlers module¶
Error handlers for scale
-
class
error.handlers.DatabaseLogHandler(model='')¶ Bases:
logging.HandlerThis class inherits from the logging.Handler class to provide support for logging messages to a database table.
-
emit(record)¶ Saves the record object to a database using the Django model class
Parameters: record (LogRecord) – Record object to save to the database
-
get_model(model_name)¶ Retrieves the given Django model given the name
Parameters: model_name (str) – The name of the model to retrieve
-
handleError(record)¶ Handles an exception that happened within the emit method
Parameters: record (LogRecord) – Record object to save to the database
-
model= None¶
-
error.models module¶
Defines the database models for errors
-
class
error.models.Error(*args, **kwargs)¶ Bases:
django.db.models.base.ModelRepresents an error that occurred during processing
Parameters: - name (
django.db.models.CharField) – The identifying name of the error - job_type_name (
django.db.models.CharField) – The name of the job type that relates to this error - title (
django.db.models.CharField) – The human-readable name of the error - description (
django.db.models.CharField) – A longer description of the error - category (
django.db.models.CharField) – The category of the error - is_builtin (
django.db.models.BooleanField) – Where the error is a builtin Scale error that does not relate to a particular job type - should_be_retried (
django.db.models.BooleanField) – Whether a job failure with this error should be automatically retried - created (
django.db.models.DateTimeField) – When the error model was created - last_modified (
django.db.models.DateTimeField) – When the error model was last modified
-
CATEGORIES= ((u'SYSTEM', u'SYSTEM'), (u'ALGORITHM', u'ALGORITHM'), (u'DATA', u'DATA'))¶
-
exception
DoesNotExist¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
category¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
created¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
description¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
get_category_display(*moreargs, **morekwargs)¶
-
get_next_by_created(*moreargs, **morekwargs)¶
-
get_next_by_last_modified(*moreargs, **morekwargs)¶
-
get_previous_by_created(*moreargs, **morekwargs)¶
-
get_previous_by_last_modified(*moreargs, **morekwargs)¶
-
id¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
is_builtin¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
job_set¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
job_type_name¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
jobexecutionend_set¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
last_modified¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
metricserror_set¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
-
name¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
natural_key()¶ Django method to define the natural key for an error as the name
Returns: A tuple representing the natural key Return type: tuple
-
objects= <error.models.ErrorManager object>¶
-
should_be_retried¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
title¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name (
-
class
error.models.ErrorManager¶ Bases:
django.db.models.manager.ManagerProvides additional methods for handling errors
-
cache_builtin_errors()¶ Queries all errors that are built into the system and caches them for fast retrieval
-
get_by_natural_key(job_type_name, error_name)¶ Django method to retrieve an error for the given natural key
Parameters: - job_type_name (string) – The name of the job type
- name (string) – The name of the error
Returns: The error defined by the natural key
Return type:
-
get_errors(started=None, ended=None, order=None, is_builtin=None, job_type_name=None, name=None, category=None)¶ Returns a list of errors within the given time range.
Parameters: - started (
datetime.datetime) – Query errors updated after this amount of time. - ended (
datetime.datetime) – Query errors updated before this amount of time. - order ([string]) – A list of fields to control the sort order.
- is_builtin (bool) – Query errors that match the is_builtin flag
- job_type_name – Query errors that match the given job type name
- name (string) – Query errors with the given name
- category (string) – Query errors with the given category.
Returns: The list of errors that match the given filters
Return type: - started (
-
save_job_error_models(job_type_name, error_models)¶ Saves the given job error models to the database
Parameters: - job_type_name (string) – The job type name
- error_models (
list()) – The error models
-
-
class
error.models.LogEntry(*args, **kwargs)¶ Bases:
django.db.models.base.ModelRepresents a log entry that occurred during processing
Parameters: - host (
django.db.models.CharField) – The name of the cluster node that generated the LogRecord - level (
django.db.models.CharField) – The severity/importance of the log entry - message (
django.db.models.TextField) – The message generated from the cluster node - created (
django.db.models.DateTimeField) – When the log entry was created - stacktrace (
django.db.models.TextField) – A stack trace of the LogRecord if one is available
-
exception
DoesNotExist¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
created¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
get_next_by_created(*moreargs, **morekwargs)¶
-
get_previous_by_created(*moreargs, **morekwargs)¶
-
host¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
id¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
level¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
message¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects= <django.db.models.manager.Manager object>¶
-
stacktrace¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- host (
-
error.models.get_builtin_error(name)¶ Returns the builtin error with the given name
Parameters: name (string) – The name of the error Returns: The error with the given name Return type: error.models.Error
-
error.models.get_error(error_id)¶ Returns the error with the given ID, might require database access if the error is not currently cached
Parameters: error_id (int) – The ID of the error Returns: The error with the given ID Return type: error.models.Error
-
error.models.get_job_error(job_type_name, error_name)¶ Returns the job error with the given name, might require database access if the error is not currently cached
Parameters: - job_type_name (string) – The name of the job type
- error_name (string) – The name of the error
Returns: The error with the given name
Return type:
-
error.models.get_unknown_error()¶ Returns the error for an unknown cause
Returns: The unknown error Return type: error.models.Error
-
error.models.reset_error_cache()¶ Resets the error cache, used for testing
error.serializers module¶
Defines the serializers for errors
-
class
error.serializers.ErrorBaseSerializerV6(instance=None, data=<class rest_framework.fields.empty>, **kwargs)¶ Bases:
util.rest.ModelIdSerializerConverts error model fields to REST output
-
class
error.serializers.ErrorDetailsSerializerV6(instance=None, data=<class rest_framework.fields.empty>, **kwargs)¶ Bases:
error.serializers.ErrorSerializerV6Converts error model fields to REST output
-
class
error.serializers.ErrorSerializerV6(instance=None, data=<class rest_framework.fields.empty>, **kwargs)¶ Bases:
error.serializers.ErrorBaseSerializerV6Converts error model fields to REST output
error.urls module¶
Defines the URLs for the RESTful recipe services
error.views module¶
-
class
error.views.ErrorDetailsView(**kwargs)¶ Bases:
rest_framework.generics.GenericAPIViewThis view is the endpoint for retrieving details of an error.
-
get(request, error_id)¶ Retrieves the details for an error and return them in JSON form
Parameters: - request (
rest_framework.request.Request) – the HTTP GET request - error_id (int encoded as a str) – The id of the error
Return type: rest_framework.response.ResponseReturns: the HTTP response to send back to the user
- request (
-
patch(request, error_id)¶ Edits an existing error and returns the updated model :param request: the HTTP PATCH request :type request:
rest_framework.request.Request:param error_id: The id of the error :type error_id: int encoded as a str :rtype:rest_framework.response.Response:returns: the HTTP response to send back to the user
-
queryset¶
-
serializer_class¶ alias of
ErrorDetailsSerializerV6
-
-
class
error.views.ErrorsView(**kwargs)¶ Bases:
rest_framework.generics.GenericAPIViewThis view is the endpoint for retrieving the list of all errors and creating a new error.
-
get(request)¶ Retrieves the list of all errors and returns it in JSON form
Parameters: request ( rest_framework.request.Request) – the HTTP GET requestReturn type: rest_framework.response.ResponseReturns: the HTTP response to send back to the user
-
post(request)¶ Creates a new error and returns a link to the info URL
Parameters: request ( rest_framework.request.Request) – the HTTP POST requestReturn type: rest_framework.response.ResponseReturns: the HTTP response to send back to the user
-
queryset¶
-
serializer_class¶ alias of
ErrorSerializerV6
-
Module contents¶
The standard interface for errors in scale