Skip to content

Commit a76bc37

Browse files
committed
edge case
1 parent f2e8d0e commit a76bc37

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

zephyr_ml/core.py

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ def log_next_producer_step(self, name):
8787

8888
if next_step >= len(self.ordered_steps):
8989
cur_step_name = self.or_join(self.ordered_steps[self.current_step][0])
90-
LOGGER.warning((f"[GUIDE] Successfully performed {name}.\n"
90+
LOGGER.warning((f"[GUIDE] DONE: {name}.\n"
9191
f"\tYou have reached the end of the "
9292
f"predictive engineering workflow.\n"
9393
f"\tYou can call {cur_step_name} again or re-perform previous steps "
9494
f"based on results."))
9595
else:
9696
next_step_name = self.or_join(self.ordered_steps[next_step][0])
97-
LOGGER.warning(f"[GUIDE] Successfully performed {name}.\n"
97+
LOGGER.warning(f"[GUIDE] DONE: {name}.\n"
9898
f"\tYou can perform the next step by calling {next_step_name}.")
9999

100100
def perform_producer_step(self, zephyr, method,
@@ -112,13 +112,13 @@ def try_log_forward_set_method_warning(self, name, next_step):
112112
f"step {next_step} by performing {name}.")
113113
else:
114114
from_str = (f"Performing step {next_step} with {name}.")
115-
LOGGER.warning((f"[GUIDE] STALE WARNING: \n"
115+
LOGGER.warning((f"[GUIDE] STALE WARNING: {name}.\n"
116116
f"\t{from_str}\n"
117117
f"\tThis is a forward step via a set method.\n"
118118
f"\tAll previous steps' results will be considered stale."))
119119

120120
def try_log_backwards_set_method_warning(self, name, next_step):
121-
LOGGER.warning((f"[GUIDE] STALE WARNING: \n"
121+
LOGGER.warning((f"[GUIDE] STALE WARNING: {name}.\n"
122122
f"\tGoing from step {self.current_step} to "
123123
f"step {next_step} by performing {name}.\n"
124124
f"\tThis is a backwards step via a set method.\n"
@@ -133,7 +133,7 @@ def try_log_backwards_key_method_warning(self, name, next_step):
133133
else:
134134
steps_in_between_str = ""
135135

136-
LOGGER.warning((f"[GUIDE] STALE WARNING:\n"
136+
LOGGER.warning((f"[GUIDE] STALE WARNING: {name}.\n"
137137
f"\tGoing from step {self.current_step} to "
138138
f"step {next_step} by performing {name}.\n"
139139
f"\tThis is a backwards step via a key method.\n"
@@ -143,13 +143,14 @@ def log_get_inconsistent_warning(self, name, next_step):
143143
prod_steps_str = self.or_join(self.ordered_steps[next_step][0])
144144
prod_steps = f"{next_step}.{prod_steps_str}"
145145
latest_up_to_date = self.get_last_up_to_date(next_step)
146-
LOGGER.warning((f"[GUIDE] INCONSISTENCY WARNING: Unable to perform {name} because"
146+
LOGGER.warning((f"[GUIDE] INCONSISTENCY WARNING: {name}.\n"
147+
f"Unable to perform {name} because"
147148
f"{prod_steps} has not been run yet.\n"
148149
f"Run steps starting at or before {latest_up_to_date}."))
149150

150151
def log_get_stale_warning(self, name, next_step):
151152
latest_up_to_date = self.get_last_up_to_date(next_step)
152-
LOGGER.warning((f"[GUIDE] STALE WARNING: Performing {name}.\n"
153+
LOGGER.warning((f"[GUIDE] STALE WARNING: {name}.\n"
153154
f"This data is potentially stale.\n"
154155
f"Re-run steps starting at or before {latest_up_to_date}"
155156
f"to ensure data is up to date."))
@@ -217,42 +218,52 @@ def try_perform_inconsistent_producer_step( # add using stale and overwriting
217218
# not up to date
218219
if (next_step >= self.current_step and
219220
self.iterations[next_step - 1] != self.cur_iteration):
220-
corr_set_method = self.or_join(self.ordered_steps[next_step][1])
221221
prev_step = next_step - 1
222222
prev_set_method = self.or_join(self.ordered_steps[prev_step][1])
223223
prev_key_method = self.or_join(self.ordered_steps[prev_step][0])
224-
LOGGER.warning(f"[GUIDE] INCONSISTENCY WARNING:\n"
224+
if next_step == len(self.ordered_steps) - 1:
225+
final_text = (f"\tOtherwise, you can regenerate the data of the previous "
226+
f"step by calling {prev_key_method}, and then call {name} again.")
227+
else:
228+
corr_set_method = self.or_join(self.ordered_steps[next_step][1])
229+
final_text = (f"\tIf you already have the data for THIS step, you can use "
230+
f"{corr_set_method} to set the data.\n"
231+
f"\tOtherwise, you can regenerate the data of the "
232+
f"previous step by calling {prev_key_method}, "
233+
f"and then call {name} again.")
234+
LOGGER.warning(f"[GUIDE] INCONSISTENCY WARNING: {name}\n"
225235
f"\tUnable to perform {name} because you are "
226236
f"performing a key method at step {next_step} but the result of the "
227237
f"previous step, step {prev_step}, is stale.\n"
228238
f"\tIf you want to use the stale result or "
229-
f"already have the data for step {prev_step}, you can use the "
230-
f"corresponding set method: {prev_set_method}.\n"
231-
f"\tIf you already have the data for THIS step, you can call "
232-
f"{corr_set_method} to set the data.\n"
233-
f"\tOtherwise, you can regenerate the data of the "
234-
f"previous step by calling {prev_key_method}, "
235-
f"and then recall this method.")
239+
f"already have the data for step {prev_step}, you can use "
240+
f"{prev_set_method} to set the data.\n"
241+
f"{final_text}")
236242
elif (next_step < self.current_step and
237243
self.iterations[next_step - 1] != self.cur_iteration):
238244
prev_step = next_step - 1
239245
prev_key_method = self.or_join(self.ordered_steps[prev_step][0])
240-
corr_set_method = self.or_join(self.ordered_steps[next_step][1])
241246
prev_set_method = self.or_join(self.ordered_steps[prev_step][1])
242-
LOGGER.warning(f"[GUIDE] INCONSISTENCY WARNING:\n"
247+
248+
if next_step == len(self.ordered_steps) - 1:
249+
final_text = (f"\tOtherwise, you can regenerate the data of the previous "
250+
f"step by calling {prev_key_method}, and then call {name} again.")
251+
else:
252+
corr_set_method = self.or_join(self.ordered_steps[next_step][1])
253+
final_text = (f"\tIf you already have the data for THIS step, you can use "
254+
f"{corr_set_method} to set the data.\n"
255+
f"\tOtherwise, you can regenerate the data of the "
256+
f"previous step by calling {prev_key_method}, "
257+
f"and then call {name} again.")
258+
LOGGER.warning(f"[GUIDE] INCONSISTENCY WARNING: {name}\n"
243259
f"\tUnable to perform {name} because "
244260
f"you are going backwards and starting a new iteration by "
245261
f"performing a key method at step {next_step} but the result of the "
246262
f"previous step, step {prev_step}, is STALE.\n"
247263
f"\tIf you want to use the STALE result or "
248-
f"already have the data for step {prev_step}, you can use the "
249-
f"corresponding set method: {prev_set_method}.\n"
250-
f"\tIf you already have the data for THIS step, you can call "
251-
f"{corr_set_method} to set the data.\n"
252-
f"\tOtherwise, you can regenerate the data of the "
253-
f"previous step by calling {prev_key_method}, "
254-
f"and then recall this method."
255-
)
264+
f"already have the data for step {prev_step}, you can use "
265+
f"{prev_set_method} to set the data.\n"
266+
f"{final_text}")
256267

257268
def try_perform_getter_step(
258269
self, zephyr, method, *method_args, **method_kwargs):
@@ -424,7 +435,6 @@ def generate_entityset(
424435
raise ValueError(
425436
f"Invalid entityset type: {es_type}. Please use one of the following types:\
426437
{VALIDATE_DATA_FUNCTIONS.keys()}")
427-
428438
entityset = _create_entityset(dfs, es_type, custom_kwargs_mapping)
429439

430440
# perform signal processing

0 commit comments

Comments
 (0)