Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve check of already made toydata and output #128

Merged
merged 6 commits into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions alea/submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,31 @@ def computation_tickets_generator(self):
+ " ".join(map(shlex.quote, script.split(" ")))
)

output_filename = i_args["output_filename"]
if (
(output_filename is not None)
and os.path.exists(output_filename)
and not self.resubmit
and self.computation != "threshold"
):
continue
else:
yield script, output_filename
if not self.already_done(i_args):
yield script, i_args["output_filename"]

def already_done(self, i_args: dict) -> bool:
"""Check if the job is already done, considering the modes of toydata and output."""
toydata_mode = i_args["toydata_mode"]
toydata_filename = i_args["toydata_filename"]
only_toydata = i_args["only_toydata"]
output_filename = i_args["output_filename"]
# these check might need change if we support more modes
if (toydata_mode == "generate_and_store") and (toydata_filename is None):
raise ValueError(
"toydata_filename should be provided when toydata_mode is generate_and_store."
)
if (not only_toydata) and (output_filename is None):
raise ValueError("output_filename should be provided when only_toydata is False.")

is_done = True
if self.resubmit or (self.computation == "threshold"):
is_done = False
if (toydata_mode == "generate_and_store") and (not os.path.exists(toydata_filename)):
is_done = False
if (not only_toydata) and (not os.path.exists(output_filename)):
is_done = False
return is_done

@staticmethod
def update_n_batch(runner_args):
Expand Down
Loading