-
Notifications
You must be signed in to change notification settings - Fork 0
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
Upload segmentation models after segmentation training completes #31
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
from tqdm import tqdm | ||
|
||
from htr2hpc.api_client import eScriptoriumAPIClient | ||
from htr2hpc.train.data import get_training_data, get_model | ||
from htr2hpc.train.data import get_training_data, get_model, upload_models | ||
from htr2hpc.train.slurm import segtrain, slurm_job_status, slurm_job_queue_status | ||
|
||
|
||
|
@@ -99,6 +99,14 @@ def main(): | |
action="store_true", | ||
default=False, | ||
) | ||
# control progress bar display (on by default) | ||
parser.add_argument( | ||
"--progress", | ||
help="Show progress", | ||
action=argparse.BooleanOptionalAction, | ||
default=True, | ||
dest="show_progress", | ||
) | ||
|
||
# training for transcription requires a transcription id | ||
transcription_parser.add_argument( | ||
|
@@ -145,7 +153,7 @@ def main(): | |
|
||
logging.basicConfig(encoding="utf-8", level=logging.WARN) | ||
logger_upscope = logging.getLogger("htr2hpc") | ||
logger_upscope.setLevel(logging.DEBUG) | ||
logger_upscope.setLevel(logging.INFO) | ||
|
||
api = eScriptoriumAPIClient(args.base_url, api_token=api_token) | ||
|
||
|
@@ -174,11 +182,6 @@ def main(): | |
# kraken default defs are path objects | ||
model_file = default_model[args.mode] | ||
|
||
# - get input data for that job | ||
# - run the bash app with the slurm provider | ||
# - get the result from the bash app and check for failure/success | ||
# | ||
|
||
# create a directory and path for the output model file | ||
output_model_dir = args.work_dir / "output_model" | ||
# currently assuming model dir is empty | ||
|
@@ -192,6 +195,9 @@ def main(): | |
abs_model_file = model_file.absolute() | ||
abs_output_modelfile = output_modelfile.absolute() | ||
|
||
# store the path to original working directory before changing directory | ||
orig_working_dir = pathlib.Path.cwd() | ||
|
||
# change directory to working directory, since by default, | ||
# slurm executes the job from the directory where it was submitted | ||
os.chdir(args.work_dir) | ||
|
@@ -215,6 +221,7 @@ def main(): | |
with tqdm( | ||
desc=f"Slurm job {job_id}", | ||
bar_format="{desc} | total time: {elapsed}{postfix} ", | ||
disable=not args.show_progress, | ||
) as statusbar: | ||
running = False | ||
while job_status: | ||
|
@@ -239,8 +246,21 @@ def main(): | |
job_output = args.work_dir / f"segtrain_{job_id}.out" | ||
print(f"Job output should be in {job_output}") | ||
|
||
# TODO: after run completes, check for results | ||
# change back to original working directory | ||
os.chdir(orig_working_dir) | ||
|
||
# after run completes, check for results | ||
# - for segmentation, upload all models to eScriptorium as new models | ||
upload_count = upload_models( | ||
api, | ||
output_modelfile.parent, | ||
es_model_jobs[args.mode], | ||
show_progress=args.show_progress, | ||
) | ||
# - does this behavior depend on job exit status? | ||
# reasonable to assume any model files created should be uploaded¿ | ||
Comment on lines
+260
to
+261
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for segmentation, yes any model files in the directory should be uploaded, even if the training process exits early for some reason. we will want to discuss best practices for handling transcription results when a |
||
|
||
print(f"Uploaded {upload_count} segmentation models to eScriptorium") | ||
|
||
# TODO: handle transcription training | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On kinds of errors/exceptions:
Quota disk storage
, if something like that comes to be enforced.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also occurs to me that the cluster sometimes has downtime, so add that to the list of possibilities to account for.