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

Handling exceptions #4

Closed
ymoisan opened this issue Sep 26, 2018 · 3 comments
Closed

Handling exceptions #4

ymoisan opened this issue Sep 26, 2018 · 3 comments

Comments

@ymoisan
Copy link
Contributor

ymoisan commented Sep 26, 2018

Add Try blocks to the code to handle exceptions where needed.

Interesting references:
https://www.pythonforthelab.com/blog/learning-not-to-handle-exceptions/
https://www.tutorialspoint.com/python/python_exceptions.htm

@ymoisan ymoisan added the P2 Medium priority label Sep 26, 2018
@epeterson12 epeterson12 self-assigned this Oct 23, 2018
@epeterson12
Copy link
Contributor

Expected behaviors should be agreed upon before we change our code to handle exceptions. This is a summary of how I think the program throws an exception during certain actions. Warnings should notify the user that the action couldn't be completed, such as an image not being able to be used for various reasons, then continue running with the rest of the data. Failures should notify the user and terminate the program.

images_to_samples.py

Risky Behavior Expected Response Function Notes
Load config.yaml Fail main()
Load S3 bucket Fail main()
Get prep.csv from bucket Fail main()
Get prep.csv from local Fail main()
Get images from bucket Warn main()
Get images from local Warn main()
Create temp h5py files Fail main()
Get shp file from bucket Fail main()
Get shp file from local Fail main()
Assert band number Warn main()
Create shp raster image Warn main()
Validate num classes Warn main()
Read images and mask Warn main()
Create shp raster image Warn main()
Create masked raster Warn main()
Create h5py files Fail main()
Delete temp label tif Warn main()
Delete temp hdf5 files Warn main()
Add samples to the bucket Fail main()
Add labels to bucket Warn main()
Delete files downloaded from S3 bucket Warn main()

train_model.py

Risky Behavior Expected Response Function Notes
Load config.yaml Fail main()
Load S3 bucket Fail main()
Load samples from bucket Fail main()
Create dataloaders Fail main()
Save intermediate checkpoint Fail main()
Save final Checkpoint Fail main()
Write model to bucket Fail main()
Check trn sample count Fail verify_sample_count()
Check val sample count Fail verify_sample_count()
Metrics logger Warn train()
Metrics logger Warn validation()

image_classification.py

Risky Behavior Expected Response Function Notes
Load config.yaml Fail main()
Load S3 bucket Fail main()
Load model from bucket Fail main()
Load images to classify from bucket Warn main()
Assert Band number Warn main()
Read image as array Warn classification()
Create new raster from base Warn classification()

@epeterson12
Copy link
Contributor

After discussion with ymoisan, we should set a limit to the number of warnings that we give. Once the threshold has been exceeded, the program should throw an exception and terminate. We would do this in case of systematic user error, for example trying to load images only in pdf format or having a different band number or number of classes in the config.yaml compared to the images in use.

mpelchat04 pushed a commit that referenced this issue Nov 27, 2018
Updating fork for gpkg update
@epeterson12 epeterson12 removed their assignment Dec 5, 2018
@ymoisan ymoisan removed P2 Medium priority labels Feb 18, 2019
@remtav remtav added Epic and removed Epic labels May 1, 2020
@remtav remtav added this to the V2 milestone May 1, 2020
@mpelchat04
Copy link
Collaborator

Relevant exceptions are being implemented ad hoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants