1616logger = daiquiri .getLogger (__name__ )
1717
1818
19+ def events_and_slots (resources ):
20+ slots = defn .slots (resources )
21+ events = defn .events (resources )
22+ unavailability = defn .unavailability (resources , slots )
23+ clashes = defn .clashes (resources )
24+ unsuitability = defn .unsuitability (resources , slots )
25+
26+ defn .add_unavailability_to_events (events , slots , unavailability )
27+ defn .add_clashes_to_events (events , clashes )
28+ defn .add_unsuitability_to_events (events , slots , unsuitability )
29+ return events , slots
30+
31+
1932@click .version_option (message = '%(prog)s %(version)s :: UK Python Association' )
2033@click .group ()
2134@click .option (
@@ -62,16 +75,7 @@ def build(
6275 session .folders ['build' ] = Path (build_dir )
6376
6477 resources = defn .resources ()
65- slots = defn .slots (resources )
66- events = defn .events (resources )
67- unavailability = defn .unavailability (resources , slots )
68- clashes = defn .clashes (resources )
69- unsuitability = defn .unsuitability (resources , slots )
70- allocations = defn .allocations (resources )
71-
72- defn .add_unavailability_to_events (events , slots , unavailability )
73- defn .add_clashes_to_events (events , clashes )
74- defn .add_unsuitability_to_events (events , slots , unsuitability )
78+ events , slots = events_and_slots (resources )
7579
7680 kwargs = {}
7781 if objective == 'consistency' or diff :
@@ -96,6 +100,7 @@ def build(
96100 logger .debug (f'{ item .event .name } has moved from { item .old_slot .venue } at { item .old_slot .starts_at } to { item .new_slot .venue } at { item .new_slot .starts_at } ' )
97101
98102 if solution is not None :
103+ allocations = defn .allocations (resources )
99104 defn .add_allocations (events , slots , solution , allocations )
100105 logger .debug (convert .schedule_to_text (solution , events , slots ))
101106 io .export_solution_and_definition (resources , events , slots , solution )
@@ -107,18 +112,35 @@ def build(
107112 '--verbosity' , '-v' , default = 'info' ,
108113 type = click .Choice (['critical' , 'error' , 'warning' , 'info' , 'debug' ]),
109114 help = 'Logging verbosity' )
115+ @click .option (
116+ '--input_dir' , '-i' , default = None , help = 'Directory for input files' )
110117@click .option (
111118 '--solution_dir' , '-s' , default = None , help = 'Directory for solution files' )
119+ @click .option (
120+ '--reload/--no-reload' , default = False , help = 'Reload YAML definition' )
112121@timed
113- def validate (verbosity , solution_dir ):
122+ def validate (verbosity , input_dir , solution_dir , reload ):
114123 logging .setup (verbosity )
115124 if solution_dir :
116125 session .folders ['solution' ] = Path (solution_dir )
117126
118127 solution = io .import_solution ()
119- definition = io .import_schedule_definition ()
128+
129+ if reload :
130+ resources = defn .resources ()
131+ events , slots = events_and_slots (resources )
132+ original_solution = io .import_solution ()
133+ solution = [
134+ item for item in original_solution
135+ if item [0 ] < len (events )]
136+ else :
137+ solution = io .import_solution ()
138+ definition = io .import_schedule_definition ()
139+ events = definition ['events' ]
140+ slots = definition ['slots' ]
141+
120142 logger .info ('Validating schedule...' )
121- if is_valid_solution (solution , definition [ ' events' ], definition [ ' slots' ] ):
143+ if is_valid_solution (solution , events , slots ):
122144 logger .info ('Imported solution is valid' )
123145 else :
124146 for v in solution_violations (
0 commit comments