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

Add optional destination folder in download_models CLI command #387

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

vasudev-sharma
Copy link
Contributor

@vasudev-sharma vasudev-sharma commented Nov 10, 2020

This PR aims to add an optional flag -p / --path and resolves some of the issued while using download_models CLI command to retrieve the models (SEM and TEM) stored on the OSF in a specific destination folder.

Usage
download_models -p destination_folder

Modifications:

  1. Using CLI, user is able to download the models in a specific destination folder.
  2. Fixes the bug which is caused when one tries download models in the working directory.
  3. Fix bug which is encountered when user tries to download model by calling downlaod_models cli command in directory different from root directory

Testing Instructions

  1. First, check-p/--pathflag works in terminal.
    -Go to terminal, and run download_models -p destination_folder_path. (Note path to destination folder path
    could either be absolute or relative)
    - SEM and TEM models would be saved under the given destination folder.
  2. Second, go to the working directory and set the destination folder to the working directory.
    - Assume the working directory to be axondeepseg, run the cli command download_models
    by setting the -p flag to be current working directory, that is,
    download_models -p /Users/vasudevsharma/VScode/Projects/axondeepseg
    - You will note that this fails in the latest master branch.
  3. Third, check whether additional directories are created when download_models cli command is executed in a directory different from root directory.
    - To test this error, follow this comment in both the master branch and vs74/download_model_cli_download_folder branch of this PR.

Resolves #323, Resolves #389, Resolves #394

@vasudev-sharma
Copy link
Contributor Author

@mathieuboudreau or @mariehbourget could either of you review this PR?

@mathieuboudreau
Copy link
Member

mathieuboudreau commented Nov 11, 2020

Sure, I'll try to get to it later tonight

@mathieuboudreau
Copy link
Member

Just having a quick look, @vs74 the edits & logic seem a bit complicated to not have written tests for them. I recommend writing unit tests for each of the cases so that you can define the expected behaviour clearly. Beyond making this feature more stable moving forward if someone else adds more changes, it will also help me with the current review.

There is already a file for unit tests of this module, here it is: https://github.com/neuropoly/axondeepseg/blob/master/test/models/test_download_models.py. Your tests will have to be a bit more expanded than the current tests, which are only for the simplest use case we previously defined the behaviour for.

@vasudev-sharma vasudev-sharma changed the title Add optional destination folder in download_models CLI command (WIP)Add optional destination folder in download_models CLI command Nov 16, 2020
@vasudev-sharma
Copy link
Contributor Author

vasudev-sharma commented Nov 16, 2020

One question, while using the CLI command to download the models, should we create destination folder if the destination folder is non existent?

@vasudev-sharma
Copy link
Contributor Author

vasudev-sharma commented Nov 16, 2020

@mathieuboudreau , I've added some unit tests for the changes introduced in download_model.py script. Feel free to review them. Also, I haven't included the unit test for the issue #394, since I think it's not required becasue I fixed the harcoded paths in commit (cc83bed). Let me know what you think about it

@vasudev-sharma vasudev-sharma changed the title (WIP)Add optional destination folder in download_models CLI command Add optional destination folder in download_models CLI command Nov 16, 2020
@mathieuboudreau
Copy link
Member

One question, while using the CLI command to download the models, should we create destination folder if the destination folder is non existent?

Yup

if destination is None:
sem_destination = Path("AxonDeepSeg/models/default_SEM_model")
tem_destination = Path("AxonDeepSeg/models/default_TEM_model")
sem_destination = Path(__file__).parent / "default_SEM_model"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the test coverage analysis, these two lines are missed by the tests. @vs74 could you add an additional test that deals with this case?

Capture d’écran 2020-11-16 à 10 49 40

Copy link
Contributor Author

@vasudev-sharma vasudev-sharma Nov 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the thing is that when destination is None, the models get saved in the deafult AxonDeepSeg/models directory. Adding another test to cover these lines, would add an extra overhead in Travis CI testing since these lines would be executed twice: first during pip install -e . and second during testing, which would overwrite the existing models stored in default directory, AxonDeepSeg/models/. Do you think it's a good idea to do that?

@vasudev-sharma
Copy link
Contributor Author

We will deal with this once ivadomed-ads integration is completed. Adding this PR in draft mode so as to avoid confusion with the new PR's.

@vasudev-sharma vasudev-sharma marked this pull request as draft November 30, 2020 05:26
@mathieuboudreau
Copy link
Member

Stale PR, closing.

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