7.2.2. xgt.Job¶
-
class
xgt.
Job
(conn, job_response, query_plan=None)¶ Represents a user-scheduled Job.
An instance of this object is created by job-scheduling functions like xgt.Connection.run_job and xgt.Connection.schedule_job.
A Job is used as a proxy for a job in the server and allows the user to monitor its execution, possibly cancel it, and learn about its status during and after execution.
The conn parameter represents a previously established connection to the xGT server.
The job_response parameter is a single element of the array returned by the output of a job creation gRPC call. Each individual element in the array will be constructed as a separate Job object.
Methods
__init__
(conn, job_response[, query_plan])Constructor for Job.
get_data
([offset, length])Returns immediate results data starting at a given offset and spanning a given length.
get_data_pandas
([offset, length])Returns a Pandas DataFrame containing immediate results data starting at a given offset and spanning a given length.
Attributes
A description supplied when the job was started.
Date and time when the job finished running.
User-friendly error message describing the reason a job failed.
Class that belongs to the XgtError hierarchy that corresponds to the original exception type thrown that caused the Job to fail.
Identifier of the job.
For internal use.
For internal use.
Gets the property names and types of the stored immediate results.
Date and time when the job was scheduled.
Status of the job.
For internal use.
Gets the number of rows of the query results.
The total number of edges traversed during the job.
Very detailed error message for a failed job.
User that ran the job.
A dictionary mapping Cypher bound variable names to an integer giving the number of edges visited during the job for the Edge Frame referenced by the bound variable.
-
__init__
(conn, job_response, query_plan=None)¶ Constructor for Job. Called when Job is created.
-
property
description
¶ A description supplied when the job was started. Usually a query.
- Type
str
-
property
end_time
¶ Date and time when the job finished running.
This is a formatted string that has a resolution of seconds.
- Type
str
-
property
error
¶ User-friendly error message describing the reason a job failed.
- Type
str
-
property
error_type
¶ Class that belongs to the XgtError hierarchy that corresponds to the original exception type thrown that caused the Job to fail.
- Type
object
-
get_data
(offset=0, length=None)¶ Returns immediate results data starting at a given offset and spanning a given length.
- Parameters
offset (int) – Position (index) of the first row to be retrieved. Optional. Default=0.
length (int) – Maximum number of rows to be retrieved starting from the row indicated by offset. A value of ‘None’ means ‘all rows’ on and after the offset. Optional. Default=None.
- Returns
- Return type
list of lists
-
get_data_pandas
(offset=0, length=None)¶ Returns a Pandas DataFrame containing immediate results data starting at a given offset and spanning a given length.
- Parameters
offset (int) – Position (index) of the first row to be retrieved. Optional. Default=0.
length (int) – Maximum number of rows to be retrieved starting from the row indicated by offset. A value of ‘None’ means ‘all rows’ on and after the offset. Optional. Default=None.
- Returns
- Return type
Pandas DataFrame
-
property
id
¶ Identifier of the job.
A 64-bit integer value that uniquely identifies a job. It is automatically incremented for each scheduled job over the lifetime of the xGT server process.
- Type
int
-
property
query_plan
¶ For internal use.
-
property
query_plan_as_cypher
¶ For internal use.
-
property
schema
¶ Gets the property names and types of the stored immediate results.
- Type
list of lists
-
property
start_time
¶ Date and time when the job was scheduled.
This is a formatted string that has a resolution of seconds.
- Type
str
-
property
status
¶ Status of the job.
Job status
Status
Description
scheduled
The state after the job has been created, but before it has started running.
running
The job is being executed.
completed
The job finished successfully.
canceled
The job was canceled.
failed
The job failed. When the job fails the error and trace properties are populated.
rollback
The job had a transactional conflict with another job and was rolled back.
unknown_job_status
The job was not found in job history.
- Type
str
-
property
timing
¶ For internal use.
-
property
total_rows
¶ Gets the number of rows of the query results. Note that this is >= than the number of rows of data extracted to the job. To get the full results the query can be executed again using an INTO clause to a named results Table.
- Type
int
-
property
total_visited_edges
¶ The total number of edges traversed during the job. This is the sum of the counts for all edge labels returned in visited_edges.
For the example given in the visited_edges documentation, the value of total_visited_edges would be 16.
- Type
int
-
property
trace
¶ Very detailed error message for a failed job.
This error message contains the friendly error message and a stack strace for the code that participated in the error.
- Type
str
-
property
user
¶ User that ran the job.
A string that identifies the user who ran the job.
- Type
str
-
property
visited_edges
¶ A dictionary mapping Cypher bound variable names to an integer giving the number of edges visited during the job for the Edge Frame referenced by the bound variable.
An edge is “visited” when the query considers the edge as a match to one of the query path edges. Multiple Cypher variables can refer to the same edge frame.
Consider the query path
()-[a:graph_edges1]->()-[b:graph_edges2]->()-[c:graph_edges1]->()
with a visited_edges result ofa -> 5, b -> 7, c -> 4
. In performing the query 5 edges of type a were visited, and so on. Notice that the total number of edges visited for the frame graph_edges1 is 9 while the number of edges visited for the frame graph_edges2 is 7.- Type
dict
-