MCPcopy Create free account
hub / github.com/apache/impala / ScheduleItem

Class ScheduleItem

tests/comparison/leopard/schedule_item.py:27–96  ·  view source on GitHub ↗

This describes the run. This class generates a Job with the generate_job method. This class can be extended in the future to be able to specify to run the job on a cluster or in stress mode. Attributes: run_name (str): This is displayed on the front page. The user enters a name when

Source from the content-addressed store, hash-verified

25ID_LEN = 16
26
27class ScheduleItem(object):
28 '''This describes the run. This class generates a Job with the generate_job method.
29 This class can be extended in the future to be able to specify to run the job on a
30 cluster or in stress mode.
31
32 Attributes:
33 run_name (str): This is displayed on the front page. The user enters a name when
34 starting a custom run.
35 git_command (str): Custom command to execute before starting a run.
36 query_profile (DefaultProfile or similar)
37 parent_job (str): job_id of the parent job
38 parent_job_name (str): used for displaying the parent job name on the front page (in
39 the schedule section)
40 job_id (str): Unique string associated with this run. It is generated here and will
41 be the same in Job and Report. The file name of pickle object will be this
42 string.
43 time_limit_sec (Number): Number of seconds to run.
44 '''
45
46 def __init__(
47 self,
48 run_name='default',
49 query_profile=None,
50 time_limit_sec=24 * 3600,
51 git_command='',
52 parent_job=None):
53 self.run_name = run_name
54 self.git_command = git_command
55 self.query_profile = None
56 self.parent_job = parent_job
57 # It takes a while to extract the parent job name, so it's done in the save_pickle
58 # method in a separate thread.
59 self.parent_job_name = ''
60 self.job_id = self.generate_job_id()
61 self.time_limit_sec = time_limit_sec
62
63 def generate_job_id(self):
64 '''Generate a random string that should be unique.
65 '''
66 return ''.join([random.choice(
67 string.ascii_lowercase + string.digits) for _ in range(ID_LEN)])
68
69 def save_pickle(self):
70 from tests.comparison.leopard.controller import (
71 PATH_TO_SCHEDULE,
72 PATH_TO_FINISHED_JOBS)
73
74 def inner():
75 if self.parent_job:
76 with open(os.path.join(PATH_TO_FINISHED_JOBS,
77 self.parent_job), 'r') as f:
78 parent_job = pickle.load(f)
79 self.parent_job_name = parent_job.job_name
80
81 with open(os.path.join(PATH_TO_SCHEDULE, self.job_id), 'w') as f:
82 pickle.dump(self, f)
83
84 thread = Thread(target=inner)

Callers 2

start_runFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected