comparison piecrust/pipelines/base.py @ 1136:5f97b5b59dfe

bake: Optimize cache handling for the baking process. - Get rid of the 2-level pipeline runs... handle a single set of passes. - Go back to load/render segments/layout passes for pages. - Add descriptions of what each job batch does. - Improve the taxonomy pipeline so it doesn't re-bake terms that don't need to be re-baked. - Simplify some of the code.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 23 Apr 2018 21:47:49 -0700
parents 971b4d67e82a
children
comparison
equal deleted inserted replaced
1135:6350ee084273 1136:5f97b5b59dfe
1 import os.path 1 import os.path
2 import logging 2 import logging
3 from werkzeug.utils import cached_property 3 from werkzeug.utils import cached_property
4 from piecrust.configuration import ConfigurationError 4 from piecrust.configuration import ConfigurationError
5 from piecrust.sources.base import ContentItem
6 5
7 6
8 logger = logging.getLogger(__name__) 7 logger = logging.getLogger(__name__)
9 8
10 9
56 def __init__(self, pass_num, record_name, record_histories): 55 def __init__(self, pass_num, record_name, record_histories):
57 super().__init__(record_name, record_histories) 56 super().__init__(record_name, record_histories)
58 self.pass_num = pass_num 57 self.pass_num = pass_num
59 58
60 59
61 class PipelineJobValidateContext(_PipelineMasterProcessJobContextBase):
62 """ Context for validating jobs on subsequent step runs (i.e. validating
63 the list of jobs to run starting with the second step).
64
65 This is run on the master process, so it can access both the
66 previous and current records.
67 """
68 def __init__(self, pass_num, step_num, record_name, record_histories):
69 super().__init__(record_name, record_histories)
70 self.pass_num = pass_num
71 self.step_num = step_num
72
73
74 class PipelineJobRunContext: 60 class PipelineJobRunContext:
75 """ Context for running pipeline baking jobs. 61 """ Context for running pipeline baking jobs.
76 62
77 This is run on the worker processes, so it can only access the 63 This is run on the worker processes, so it can only access the
78 previous records. 64 previous records.
101 worker process. 87 worker process.
102 88
103 This is run on the master process, so it can access the current 89 This is run on the master process, so it can access the current
104 record. 90 record.
105 """ 91 """
106 def __init__(self, record, job, pass_num, step_num): 92 def __init__(self, record, job, pass_num):
107 self.record = record 93 self.record = record
108 self.job = job 94 self.job = job
109 self.pass_num = pass_num 95 self.pass_num = pass_num
110 self.step_num = step_num
111 96
112 @cached_property 97 @cached_property
113 def record_entry(self): 98 def record_entry(self):
114 record_entry_spec = self.job.get('record_entry_spec', 99 record_entry_spec = self.job.get('record_entry_spec',
115 self.job['job_spec'][1]) 100 self.job['job_spec'][1])
158 pass 143 pass
159 144
160 def createJobs(self, ctx): 145 def createJobs(self, ctx):
161 return [ 146 return [
162 create_job(self, item.spec) 147 create_job(self, item.spec)
163 for item in self.source.getAllContents()] 148 for item in self.source.getAllContents()], None
164 149
165 def createRecordEntry(self, item_spec): 150 def createRecordEntry(self, item_spec):
166 entry_class = self.RECORD_ENTRY_CLASS 151 entry_class = self.RECORD_ENTRY_CLASS
167 record_entry = entry_class() 152 record_entry = entry_class()
168 record_entry.item_spec = item_spec 153 record_entry.item_spec = item_spec
169 return record_entry 154 return record_entry
170 155
171 def handleJobResult(self, result, ctx): 156 def handleJobResult(self, result, ctx):
172 raise NotImplementedError() 157 raise NotImplementedError()
173
174 def validateNextStepJobs(self, jobs, ctx):
175 pass
176 158
177 def run(self, job, ctx, result): 159 def run(self, job, ctx, result):
178 raise NotImplementedError() 160 raise NotImplementedError()
179 161
180 def postJobRun(self, ctx): 162 def postJobRun(self, ctx):