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

Move to Python 3.6 compatibility #129

Merged
merged 31 commits into from
Sep 11, 2018
Merged

Move to Python 3.6 compatibility #129

merged 31 commits into from
Sep 11, 2018

Conversation

mathieuboudreau
Copy link
Member

@mathieuboudreau mathieuboudreau commented Aug 14, 2018

This branch isn't ready for merging yet, please standby. I'm simply making this PR to see the merge conflicts. There's still 3 failing tests and 1 errored test in Windows.

…ry files, so instead write to a normal file in a temp folder. Also improve invalid data format of temp file.
… in behaviour that may have unanticipated consequences (as seen from warnings)
@mathieuboudreau mathieuboudreau self-assigned this Aug 14, 2018
@mathieuboudreau
Copy link
Member Author

This branch finally passed all tests on a Windows 10 machine.

Output of py.test:


(ads36_venv) C:\Users\emb61\axondeepseg>py.test . -v --cov AxonDeepSeg/ --cov-report term-missing
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.5.0, py-1.5.4, pluggy-0.6.0 -- c:\users\emb61\appdata\local\continuum\anaconda3\envs\ads36_venv\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\emb61\axondeepseg, inifile:
plugins: cov-2.5.1
collected 68 items

test/test_config_tools.py::TestCore::test_validate_config_for_demo_config PASSED [  1%]
test/test_config_tools.py::TestCore::test_validate_config_for_invalid_config PASSED [  2%]
test/test_config_tools.py::TestCore::test_generate_config_creates_valid_config PASSED [  4%]
test/test_config_tools.py::TestCore::test_generate_config_with_config_path PASSED [  5%]
test/test_config_tools.py::TestCore::test_generate_config_with_config_path_and_invalid_config PASSED [  7%]
test/test_config_tools.py::TestCore::test_grid_config_feature_augmentation_x PASSED [  8%]
test/test_config_tools.py::TestCore::test_grid_config_feature_augmentation_p PASSED [ 10%]
test/test_config_tools.py::TestCore::test_grid_config_feature_augmentation_invalid PASSED [ 11%]
test/test_config_tools.py::TestCore::test_generate_name_config_convolution_downsampling_first_letters PASSED [ 13%]
test/test_integrity_test.py::TestCore::test_integrity_test_script_runs_successfully PASSED [ 14%]
test/test_segment.py::TestCore::test_generate_config_dict_outputs_dict PASSED [ 16%]
test/test_segment.py::TestCore::test_generate_config_dict_throws_exception_for_nonexisting_file PASSED [ 17%]
test/test_segment.py::TestCore::test_generate_resolution_returns_expected_known_project_cases PASSED [ 19%]
test/test_segment.py::TestCore::test_segment_folders_creates_expected_files PASSED [ 20%]
test/test_segment.py::TestCore::test_segment_image_creates_runs_successfully_ PASSED [ 22%]
test/test_train_network.py::TestCore::test_train_model_runs_successfully_for_simplified_case PASSED [ 23%]
test/data_management/test_data_augmentation.py::TestCore::test_shifting_returns_different_image PASSED [ 25%]
test/data_management/test_data_augmentation.py::TestCore::test_rescaling_factor_1_returns_same_image PASSED [ 26%]
test/data_management/test_data_augmentation.py::TestCore::test_large_max_rescaling_factor_returns_different_image PASSED [ 27%]
test/data_management/test_data_augmentation.py::TestCore::test_random_rotation_returns_different_image PASSED [ 29%]
test/data_management/test_data_augmentation.py::TestCore::test_elastic_returns_different_image PASSED [ 30%]
test/data_management/test_data_augmentation.py::TestCore::test_flipping_returns_different_image PASSED [ 32%]
test/data_management/test_data_augmentation.py::TestCore::test_gaussian_blur_returns_image_of_same_size PASSED [ 33%]
test/data_management/test_dataset_building.py::TestCore::test_raw_img_to_patches_creates_expected_folders_and_files PASSED [ 35%]
test/data_management/test_dataset_building.py::TestCore::test_patched_to_dataset_creates_expected_folders_and_files PASSED [ 36%]
test/data_management/test_dataset_building.py::TestCore::test_patched_to_dataset_fake_mixed_dataset_creates_expected_dir PASSED [ 38%]
test/data_management/test_patch_extraction.py::TestCore::test_extract_patch_script_returns_expected_patches PASSED [ 39%]
test/data_management/test_patch_extraction.py::TestCore::test_extract_patch_script_errors_for_patch_size_smaller_than_3 PASSED [ 41%]
test/data_management/test_patch_extraction.py::TestCore::test_extract_patch_script_errors_for_patch_size_eq_to_image_dim PASSED [ 42%]
test/data_management/test_patch_extraction.py::TestCore::test_extract_patch_script_errors_for_incorrect_first_arg_format PASSED [ 44%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_get_pixelsize_returns_expected_value PASSED [ 45%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_get_pixelsize_throws_error_for_nonexisisting_file PASSED [ 47%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_get_pixelsize_throws_error_for_invalid_data_file PASSED [ 48%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_get_axon_morphometrics_returns_expected_type PASSED [ 50%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_get_axon_morphometrics_returns_expected_keys PASSED [ 51%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_save_axon_morphometrics_creates_file_in_expected_location PASSED [ 52%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_save_axon_morphometrics_throws_error_if_folder_doesnt_exist PASSED [ 54%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_load_axon_morphometrics_returns_identical_var_as_was_saved PASSED [ 55%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_load_axon_morphometrics_throws_error_if_folder_doesnt_exist PASSED [ 57%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_display_axon_diameter_creates_file_in_expected_location PASSED [ 58%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_get_aggregate_morphometrics_returns_expected_type PASSED [ 60%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_get_aggregate_morphometrics_returns_returns_expected_keys PASSED [ 61%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_write_aggregate_morphometrics_creates_file_in_expected_location PASSED [ 63%]
test/morphometrics/test_compute_morphometrics.py::TestCore::test_write_aggregate_morphometrics_throws_error_if_folder_doesnt_exist PASSED [ 64%]
test/morphometrics/test_launch_morphometrics_computation.py::TestCore::test_launch_morphometrics_computation_saves_expected_files PASSED [ 66%]
test/morphometrics/test_launch_morphometrics_computation.py::TestCore::test_launch_morphometrics_computation_errors_for_missing_file PASSED [ 67%]
test/testing/test_launch_performance_metrics.py::TestCore::test_launch_performance_metrics_runs_successfully PASSED [ 69%]
test/testing/test_noise_simulation.py::TestCore::test_add_additive_gaussian_noise_returns_expected_std_diff PASSED [ 70%]
test/testing/test_noise_simulation.py::TestCore::test_add_multiplicative_gaussian_noise_returns_different_image PASSED [ 72%]
test/testing/test_noise_simulation.py::TestCore::test_change_brightness PASSED [ 73%]
test/testing/test_segmentation_scoring.py::TestCore::test_score_analysis_returns_nonzero_outputs_diff_masks PASSED [ 75%]
test/testing/test_segmentation_scoring.py::TestCore::test_score_analysis_returns_expected_outputs_for_same_masks PASSED [ 76%]
test/testing/test_segmentation_scoring.py::TestCore::test_score_analysis_runs_successfully_with_visualization_on PASSED [ 77%]
test/testing/test_segmentation_scoring.py::TestCore::test_dice_returns_nonempty_pandas_dataframe PASSED [ 79%]
test/testing/test_segmentation_scoring.py::TestCore::test_pwdice_returns_nonzero_value_for_diff_masks PASSED [ 80%]
test/testing/test_segmentation_scoring.py::TestCore::test_pwdice_returns_1_for_identical_masks PASSED [ 82%]
test/testing/test_segmentation_scoring.py::TestCore::test_Metrics_calculator_class_return_nonzeros_for_diff_masks PASSED [ 83%]
test/testing/test_segmentation_scoring.py::TestCore::test_Metrics_calculator_class_same_masks_returns_expected_values PASSED [ 85%]
test/testing/test_statistics_generation.py::TestCore::test_metrics_single_wrapper_runs_successfully_and_outfile_exists PASSED [ 86%]
test/testing/test_statistics_generation.py::TestCore::test_metrics_classic_wrapper_runs_successfully_and_outfile_exists PASSED [ 88%]
test/testing/test_statistics_generation.py::TestCore::test_metrics_class_loads_stats_table PASSED [ 89%]
test/testing/test_statistics_generation.py::TestCore::test_metrics_class_throws_exception_for_missing_stats_file PASSED [ 91%]
test/visualization/test_generate_axons_from_myelin.py::TestCore::test_generate_axons_from_myelin_creates_expected_file PASSED [ 92%]
test/visualization/test_get_masks.py::TestCore::test_get_masks_writes_expected_files PASSED [ 94%]
test/visualization/test_get_masks.py::TestCore::test_rgb_rendering_of_mask_returns_array_with_extra_dim_of_len_3 PASSED [ 95%]
test/visualization/test_get_masks.py::TestCore::test_rgb_rendering_of_mask_writes_expected_files PASSED [ 97%]
test/visualization/test_merge_masks.py::TestCore::test_merge_masks_outputs_expected_volume_and_writes_files PASSED [ 98%]
test/visualization/test_visualize.py::TestCore::test_visualize_training_runs_successfully PASSED [100%]

----------- coverage: platform win32, python 3.6.6-final-0 -----------
Name                                                            Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------------------------
AxonDeepSeg\__init__.py                                             1      0   100%
AxonDeepSeg\ads_utils.py                                           71     45    37%   14-57, 65-91, 110, 126, 142-154, 162-167
AxonDeepSeg\apply_model.py                                        158     17    89%   54-55, 117-137, 206, 209, 212, 230-233, 403
AxonDeepSeg\config_tools.py                                       107      1    99%   137
AxonDeepSeg\data_management\__init__.py                             0      0   100%
AxonDeepSeg\data_management\data_augmentation.py                  141     15    89%   81, 88-91, 97, 104, 110-111, 130, 142-143, 231, 260, 268
AxonDeepSeg\data_management\dataset_building.py                   115      4    97%   225-228
AxonDeepSeg\data_management\input_data.py                         191     44    77%   27, 70-74, 109-114, 178, 198, 211-241, 315-316, 354-355, 373-392, 409, 423
AxonDeepSeg\data_management\patch_extraction.py                    40      5    88%   16-18, 44-45
AxonDeepSeg\integrity_test.py                                      36      4    89%   33, 62-66
AxonDeepSeg\models\__init__.py                                      0      0   100%
AxonDeepSeg\morphometrics\__init__.py                               0      0   100%
AxonDeepSeg\morphometrics\compute_morphometrics.py                 98      2    98%   13-14
AxonDeepSeg\morphometrics\launch_morphometrics_computation.py      26      2    92%   9-10
AxonDeepSeg\network_construction.py                                78      8    90%   38, 64, 81-95
AxonDeepSeg\patch_management_tools.py                              63      3    95%   27-30
AxonDeepSeg\segment.py                                            109     38    65%   67, 93, 133, 171-176, 229-314, 318
AxonDeepSeg\testing\__init__.py                                     0      0   100%
AxonDeepSeg\testing\launch_performance_metrics.py                  26      0   100%
AxonDeepSeg\testing\noise_simulation.py                            29      0   100%
AxonDeepSeg\testing\segmentation_scoring.py                       150      5    97%   12-14, 151, 265
AxonDeepSeg\testing\statistics_generation.py                      209     60    71%   106-109, 164-167, 246-248, 315-319, 387-411, 415-431, 443-463, 466
AxonDeepSeg\train_network.py                                      297     57    81%   38, 70, 132, 138, 149, 176, 285, 328-336, 346, 376-380, 394, 416-419, 462-467, 501-503, 540-569, 627-644, 648
AxonDeepSeg\train_network_tools.py                                 49      3    94%   23-24, 60
AxonDeepSeg\trainingforhelios.py                                   26     26     0%   5-49
AxonDeepSeg\visualization\__init__.py                               0      0   100%
AxonDeepSeg\visualization\generate_axons_from_myelin.py            17      0   100%
AxonDeepSeg\visualization\get_masks.py                             28      0   100%
AxonDeepSeg\visualization\merge_masks.py                           11      0   100%
AxonDeepSeg\visualization\visualize.py                            120     83    31%   7-9, 65-151, 166-174, 187-188, 192-200
---------------------------------------------------------------------------------------------
TOTAL                                                            2196    422    81%


============================== warnings summary ===============================
test/data_management/test_data_augmentation.py::TestCore::()::test_large_max_rescaling_factor_returns_different_image
  c:\users\emb61\appdata\local\continuum\anaconda3\envs\ads36_venv\lib\site-packages\skimage\transform\_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
    warn("The default mode, 'constant', will be changed to 'reflect' in "

test/data_management/test_dataset_building.py::TestCore::()::test_raw_img_to_patches_creates_expected_folders_and_files
  c:\users\emb61\appdata\local\continuum\anaconda3\envs\ads36_venv\lib\site-packages\skimage\transform\_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
    warn("The default mode, 'constant', will be changed to 'reflect' in "

test/data_management/test_dataset_building.py::TestCore::()::test_patched_to_dataset_fake_mixed_dataset_creates_expected_dir
  c:\users\emb61\appdata\local\continuum\anaconda3\envs\ads36_venv\lib\site-packages\skimage\transform\_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
    warn("The default mode, 'constant', will be changed to 'reflect' in "

test/visualization/test_visualize.py::TestCore::()::test_visualize_training_runs_successfully
  c:\users\emb61\appdata\local\continuum\anaconda3\envs\ads36_venv\lib\site-packages\matplotlib\cbook\deprecation.py:107: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
    warnings.warn(message, mplDeprecation, stacklevel=1)

-- Docs: http://doc.pytest.org/en/latest/warnings.html
=================== 68 passed, 4 warnings in 745.10 seconds ===================
): /job:localhost/replica:0/task:0/device:CPU:0
save/SaveV2/tensor_names: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/SaveV2/shape_and_slices: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/RestoreV2/tensor_names: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/RestoreV2/shape_and_slices: (Const): /job:localhost/replica:0/task:0/device:CPU:0

(ads36_venv) C:\Users\emb61\axondeepseg>

Python version details:

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)] on win32

Virtual Environment details:


(ads36_venv) C:\Users\emb61\axondeepseg>pip list
Package         Version   Location
--------------- --------- --------------------------
absl-py         0.3.0
astor           0.7.1
attrs           18.1.0
AxonDeepSeg     2.0.dev0  c:\users\emb61\axondeepseg
certifi         2018.4.16
cloudpickle     0.5.3
colorama        0.3.9
coverage        4.5.1
cycler          0.10.0
dask            0.18.2
decorator       4.3.0
gast            0.2.0
grpcio          1.13.0
imageio         2.3.0
kiwisolver      1.0.1
Markdown        2.6.11
matplotlib      2.2.2
more-itertools  4.2.0
mpld3           0.3
networkx        2.1
numpy           1.14.5
pandas          0.23.3
Pillow          5.2.0
pip             10.0.1
pluggy          0.6.0
prettytable     0.7.2
protobuf        3.6.0
py              1.5.4
pyparsing       2.2.0
pytest          3.5.0
pytest-cov      2.5.1
python-dateutil 2.7.3
pytz            2018.5
PyWavelets      0.5.2
raven           6.8.0
scikit-image    0.13.1
scikit-learn    0.19.2
scipy           1.1.0
setuptools      39.1.0
six             1.11.0
tabulate        0.8.2
tensorboard     1.9.0
tensorflow      1.9.0
termcolor       1.1.0
toolz           0.9.0
tqdm            4.24.0
Werkzeug        0.14.1
wheel           0.31.1
wincertstore    0.2

@mathieuboudreau
Copy link
Member Author

mathieuboudreau commented Aug 14, 2018

Things that are left to do before merging and upgrading ADS to Python 3.6:

  • Fully train a model using a large dataset with full config details (non-test config) on a Python 3.6 virtual environment, and evaluate segmentation quality of trained model on a few test images.
  • Write changes to changelog
  • Update python requirements in the documentation, and explicitly indicate Windows support.
  • Test installation through pip by uploading dev version of wheel package
  • Test installation on a physical machine running Windows (non Virtual Machine)

Anything else?

@coveralls
Copy link

coveralls commented Aug 14, 2018

Coverage Status

Coverage decreased (-0.2%) to 80.135% when pulling 6a132b2 on ads36 into cca40dd on master.

@jcohenadad
Copy link
Member

@alexfoias can you do the install test on win10 once ready to merge?

@mathieuboudreau
Copy link
Member Author

On another note, I've uploaded a dev version of this version on PyPi, you can access it by running pip install axondeepseg==2.0dev. I installed it both on my Mac and on my Windows virtual machine, and the command axondeepseg_test ran successfully on both platforms after installation through pip.

@oumayb
Copy link
Contributor

oumayb commented Aug 29, 2018

@mathieuboudreau here is the result of py.test --cov AxonDeepSeg/ --cov-report term-missing

---------- coverage: platform darwin, python 3.6.6-final-0 -----------
Name Stmts Miss Cover Missing

AxonDeepSeg/init.py 1 0 100%
AxonDeepSeg/ads_utils.py 71 40 44% 14-57, 65-91, 110, 126, 153-154, 163-165
AxonDeepSeg/apply_model.py 158 17 89% 54-55, 117-137, 206, 209, 212, 230-233, 403
AxonDeepSeg/config_tools.py 107 1 99% 137
AxonDeepSeg/data_management/init.py 0 0 100%
AxonDeepSeg/data_management/data_augmentation.py 141 16 89% 81, 88-91, 97, 104, 110-111, 130, 142-143, 229, 238, 260, 268
AxonDeepSeg/data_management/dataset_building.py 115 4 97% 225-228
AxonDeepSeg/data_management/input_data.py 191 44 77% 27, 70-74, 109-114, 178, 198, 211-241, 315-316, 354-355, 373-392, 409, 423
AxonDeepSeg/data_management/patch_extraction.py 40 5 88% 16-18, 44-45
AxonDeepSeg/integrity_test.py 36 4 89% 33, 62-66
AxonDeepSeg/mapping_results.py 29 29 0% 4-60
AxonDeepSeg/models/init.py 0 0 100%
AxonDeepSeg/morphometrics/init.py 0 0 100%
AxonDeepSeg/morphometrics/compute_morphometrics.py 98 0 100%
AxonDeepSeg/morphometrics/launch_morphometrics_computation.py 26 0 100%
AxonDeepSeg/network_construction.py 78 8 90% 38, 64, 81-95
AxonDeepSeg/patch_management_tools.py 63 3 95% 27-30
AxonDeepSeg/segment.py 109 38 65% 67, 93, 133, 171-176, 229-314, 318
AxonDeepSeg/testing/init.py 0 0 100%
AxonDeepSeg/testing/launch_performance_metrics.py 26 0 100%
AxonDeepSeg/testing/noise_simulation.py 29 0 100%
AxonDeepSeg/testing/segmentation_scoring.py 150 5 97% 12-14, 151, 265
AxonDeepSeg/testing/statistics_generation.py 209 60 71% 106-109, 164-167, 246-248, 315-319, 387-411, 415-431, 443-463, 466
AxonDeepSeg/train_network.py 297 97 67% 38, 70, 132, 138, 149, 176, 285, 328-336, 346, 376-380, 394, 416-419, 462-467, 498-607, 627-644, 648
AxonDeepSeg/train_network_tools.py 49 3 94% 23-24, 60
AxonDeepSeg/trainingforhelios.py 26 26 0% 5-49
AxonDeepSeg/visualization/init.py 0 0 100%
AxonDeepSeg/visualization/generate_axons_from_myelin.py 17 0 100%
AxonDeepSeg/visualization/get_masks.py 28 0 100%
AxonDeepSeg/visualization/merge_masks.py 11 0 100%
AxonDeepSeg/visualization/visualize.py 120 83 31% 7-9, 65-151, 166-174, 187-188, 192-200

TOTAL 2225 483 78%

======================================================================================================================================== warnings summary =========================================================================================================================================
test/data_management/test_data_augmentation.py::TestCore::()::test_large_max_rescaling_factor_returns_different_image
/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "

test/data_management/test_dataset_building.py::TestCore::()::test_raw_img_to_patches_creates_expected_folders_and_files
/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "

test/data_management/test_dataset_building.py::TestCore::()::test_patched_to_dataset_fake_mixed_dataset_creates_expected_dir
/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "

test/visualization/test_visualize.py::TestCore::()::test_visualize_training_runs_successfully
/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py:107: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
warnings.warn(message, mplDeprecation, stacklevel=1)

-- Docs: http://doc.pytest.org/en/latest/warnings.html
======================================================================================================================== 1 failed, 67 passed, 4 warnings in 286.11 seconds ========================================================================================================================
): /job:localhost/replica:0/task:0/device:CPU:0
save/SaveV2/tensor_names: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/SaveV2/shape_and_slices: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/RestoreV2/tensor_names: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/RestoreV2/shape_and_slices: (Const): /job:localhost/replica:0/task:0/device:CPU:0

  • On your other note, I tested the dev version with the tests you mentioned and it passed!

@mathieuboudreau
Copy link
Member Author

@oumayb Was there anything printed above what you posted here? Usually the information on the test failure is above that (maybe copy and paste from starting from where you did your command?)

@oumayb
Copy link
Contributor

oumayb commented Aug 29, 2018

@mathieuboudreau yes sorry, the error is in the following log. I couldn't copy the whole thing because of the characters count limit.

======================================================================================================================================= test session starts =======================================================================================================================================
platform darwin -- Python 3.6.6, pytest-3.7.3, py-1.5.4, pluggy-0.7.1
rootdir: /Users/oubou_admin/axondeepseg, inifile:
plugins: cov-2.5.1
collected 68 items

test/test_config_tools.py ......... [ 13%]
test/test_integrity_test.py . [ 14%]
test/test_segment.py ..... [ 22%]
test/test_train_network.py F [ 23%]
test/data_management/test_data_augmentation.py ....... [ 33%]
test/data_management/test_dataset_building.py ... [ 38%]
test/data_management/test_patch_extraction.py .... [ 44%]
test/morphometrics/test_compute_morphometrics.py .............. [ 64%]
test/morphometrics/test_launch_morphometrics_computation.py .. [ 67%]
test/testing/test_launch_performance_metrics.py . [ 69%]
test/testing/test_noise_simulation.py ... [ 73%]
test/testing/test_segmentation_scoring.py ........ [ 85%]
test/testing/test_statistics_generation.py .... [ 91%]
test/visualization/test_generate_axons_from_myelin.py . [ 92%]
test/visualization/test_get_masks.py ... [ 97%]
test/visualization/test_merge_masks.py . [ 98%]
test/visualization/test_visualize.py . [100%]

============================================================================================================================================ FAILURES =============================================================================================================================================
_________________________________________________________________________________________________________________ TestCore.test_train_model_runs_successfully_for_simplified_case _________________________________________________________________________________________________________________

self = <tensorflow.python.client.session.Session object at 0x124b0a0f0>, fn = <function BaseSession._do_run.._run_fn at 0x12800b510>
args = ({<tensorflow.python.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70240>...n.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70180> >], [], None, None)
message = 'Nan in summary histogram for: upconv-d1/convolution/weights_0_grad\n\t [[Node: upconv-d1/convolution/weights_0_grad =...v-d1/convolution/Conv2D_grad/Conv2DBackpropFilter, ^gradients/upconv-d1/convolution/Conv2D_grad/Conv2DBackpropInput)]]'
m = <_sre.SRE_Match object; span=(69, 115), match='[[Node: upconv-d1/convolution/weights_0_grad ='>

def _do_call(self, fn, *args):
  try:
  return fn(*args)

../miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py:1322:


feed_dict = {<tensorflow.python.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70240> ...ernal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a701e0> >: array([1.0898974], dtype=float32), ...}
fetch_list = [<tensorflow.python.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70270> >, <tensorflow.python.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70180> >], target_list = [], options = None
run_metadata = None

def _run_fn(feed_dict, fetch_list, target_list, options, run_metadata):
  # Ensure any changes to the graph are reflected in the runtime.
  self._extend_graph()
  return self._call_tf_sessionrun(
    options, feed_dict, fetch_list, target_list, run_metadata)

../miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py:1307:


self = <tensorflow.python.client.session.Session object at 0x124b0a0f0>, options = None
feed_dict = {<tensorflow.python.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70240> ...ernal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a701e0> >: array([1.0898974], dtype=float32), ...}
fetch_list = [<tensorflow.python.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70270> >, <tensorflow.python.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70180> >], target_list = []
run_metadata = None

def _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list,
                        run_metadata):
  if self._created_with_new_api:
    return tf_session.TF_SessionRun_wrapper(
        self._session, options, feed_dict, fetch_list, target_list,
      run_metadata)

E tensorflow.python.framework.errors_impl.InvalidArgumentError: Nan in summary histogram for: upconv-d1/convolution/weights_0_grad
E [[Node: upconv-d1/convolution/weights_0_grad = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](upconv-d1/convolution/weights_0_grad/tag, gradients/upconv-d1/convolution/Conv2D_grad/Conv2DBackpropFilter, ^gradients/upconv-d1/convolution/Conv2D_grad/Conv2DBackpropInput)]]

../miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py:1409: InvalidArgumentError

During handling of the above exception, another exception occurred:

self = <test_train_network.TestCore object at 0x127fa4908>

@pytest.mark.integration
def test_train_model_runs_successfully_for_simplified_case(self):
    # Note: This test is simply a mock test to ensure that the pipeline
    # runs successfully, and is not a test of the quality of the model
    # itself.

    train_model(
        self.trainingPath,
        self.modelPath,
        self.config_network,
      debug_mode=True
        )

test/test_train_network.py:133:


AxonDeepSeg/train_network.py:497: in train_model
[merged_summaries, images_merged_summaries], feed_dict=feed_dict_summary_val)
../miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py:900: in run
run_metadata_ptr)
../miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py:1135: in _run
feed_dict_tensor, options, run_metadata)
../miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py:1316: in _do_run
run_metadata)


self = <tensorflow.python.client.session.Session object at 0x124b0a0f0>, fn = <function BaseSession._do_run.._run_fn at 0x12800b510>
args = ({<tensorflow.python.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70240>...n.pywrap_tensorflow_internal.TF_Output; proxy of <Swig Object of type 'TF_Output *' at 0x124a70180> >], [], None, None)
message = 'Nan in summary histogram for: upconv-d1/convolution/weights_0_grad\n\t [[Node: upconv-d1/convolution/weights_0_grad =...v-d1/convolution/Conv2D_grad/Conv2DBackpropFilter, ^gradients/upconv-d1/convolution/Conv2D_grad/Conv2DBackpropInput)]]'
m = <_sre.SRE_Match object; span=(69, 115), match='[[Node: upconv-d1/convolution/weights_0_grad ='>

def _do_call(self, fn, *args):
  try:
    return fn(*args)
  except errors.OpError as e:
    message = compat.as_text(e.message)
    m = BaseSession._NODEDEF_NAME_RE.search(message)
    node_def = None
    op = None
    if m is not None:
      node_name = m.group(1)
      try:
        op = self._graph.get_operation_by_name(node_name)
        node_def = op.node_def
      except KeyError:
        pass
  raise type(e)(node_def, op, message)

E tensorflow.python.framework.errors_impl.InvalidArgumentError: Nan in summary histogram for: upconv-d1/convolution/weights_0_grad
E [[Node: upconv-d1/convolution/weights_0_grad = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](upconv-d1/convolution/weights_0_grad/tag, gradients/upconv-d1/convolution/Conv2D_grad/Conv2DBackpropFilter, ^gradients/upconv-d1/convolution/Conv2D_grad/Conv2DBackpropInput)]]
E
E Caused by op 'upconv-d1/convolution/weights_0_grad', defined at:
E File "/Users/oubou_admin/miniconda3/bin/py.test", line 11, in
E sys.exit(main())
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/config/init.py", line 65, in main
E return config.hook.pytest_cmdline_main(config=config)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/hooks.py", line 258, in call
E return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 67, in _hookexec
E return self._inner_hookexec(hook, methods, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 61, in
E firstresult=hook.spec_opts.get('firstresult'),
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
E res = hook_impl.function(*args)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/main.py", line 208, in pytest_cmdline_main
E return wrap_session(config, _main)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/main.py", line 178, in wrap_session
E session.exitstatus = doit(config, session) or 0
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/main.py", line 215, in _main
E config.hook.pytest_runtestloop(session=session)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/hooks.py", line 258, in call
E return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 67, in _hookexec
E return self._inner_hookexec(hook, methods, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 61, in
E firstresult=hook.spec_opts.get('firstresult'),
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
E res = hook_impl.function(*args)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/main.py", line 236, in pytest_runtestloop
E item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/hooks.py", line 258, in call
E return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 67, in _hookexec
E return self._inner_hookexec(hook, methods, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 61, in
E firstresult=hook.spec_opts.get('firstresult'),
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
E res = hook_impl.function(*args)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/runner.py", line 66, in pytest_runtest_protocol
E runtestprotocol(item, nextitem=nextitem)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/runner.py", line 81, in runtestprotocol
E reports.append(call_and_report(item, "call", log))
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/runner.py", line 161, in call_and_report
E call = call_runtest_hook(item, when, **kwds)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/runner.py", line 185, in call_runtest_hook
E treat_keyboard_interrupt_as_exception=item.config.getvalue("usepdb"),
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/runner.py", line 201, in init
E self.result = func()
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/runner.py", line 183, in
E lambda: ihook(item=item, **kwds),
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/hooks.py", line 258, in call
E return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 67, in _hookexec
E return self._inner_hookexec(hook, methods, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 61, in
E firstresult=hook.spec_opts.get('firstresult'),
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
E res = hook_impl.function(*args)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/runner.py", line 111, in pytest_runtest_call
E item.runtest()
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/_pytest/python.py", line 1450, in runtest
E self.ihook.pytest_pyfunc_call(pyfuncitem=self)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/hooks.py", line 258, in call
E return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 67, in _hookexec
E return self._inner_hookexec(hook, methods, kwargs)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/manager.py", line 61, in
E firstresult=hook.spec_opts.get('firstresult'),
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
E res = hook_impl.function(*args)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/pytest/python.py", line 196, in pytest_pyfunc_call
E testfunction(**testargs)
E File "/Users/oubou_admin/axondeepseg/test/test_train_network.py", line 133, in test_train_model_runs_successfully_for_simplified_case
E debug_mode=True
E File "/Users/oubou_admin/axondeepseg/AxonDeepSeg/train_network.py", line 191, in train_model
E weight_grads_summary = tf.summary.histogram('
'.join(weight.name.split(':')) + '_grad', grad)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/tensorflow/python/summary/summary.py", line 187, in histogram
E tag=tag, values=values, name=scope)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_logging_ops.py", line 283, in histogram_summary
E "HistogramSummary", tag=tag, values=values, name=name)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
E op_def=op_def)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3414, in create_op
E op_def=op_def)
E File "/Users/oubou_admin/miniconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1740, in init
E self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
E
E InvalidArgumentError (see above for traceback): Nan in summary histogram for: upconv-d1/convolution/weights_0_grad
E [[Node: upconv-d1/convolution/weights_0_grad = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](upconv-d1/convolution/weights_0_grad/tag, gradients/upconv-d1/convolution/Conv2D_grad/Conv2DBackpropFilter, ^gradients/upconv-d1/convolution/Conv2D_grad/Conv2DBackpropInput)]]

../miniconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py:1335: InvalidArgumentError

@oumayb
Copy link
Contributor

oumayb commented Sep 5, 2018

  • @mathieuboudreau helped me work around the previous issues.
    Since the default version of Python that is installed in my computer is Python2, creating a virtual environment using virtualenv creates an environment with Python2 by default.
    The solution was to use conda and specify which Python version to use in the created virtual environment: conda create -n ads36_venv_conda python=3.6.

  • After that, all the tests pass.

  • I'll just run a training I previously ran on Python2 to make sure it works with the new version.

Outputs of py.test:

========================================================================================================================================================================== test session starts ===========================================================================================================================================================================
platform darwin -- Python 3.6.6, pytest-3.5.0, py-1.6.0, pluggy-0.6.0
rootdir: /Users/oubou_admin/axondeepseg, inifile:
plugins: cov-2.5.1
collected 68 items                                                                                                                                                                                                                                                                                                                                                       

test/test_config_tools.py .........                                                                                                                                                                                                                                                                                                                                [ 13%]
test/test_integrity_test.py .                                                                                                                                                                                                                                                                                                                                      [ 14%]
test/test_segment.py .....                                                                                                                                                                                                    [ 22%]
test/test_train_network.py .                                                                                                                                                                                                  [ 23%]
test/data_management/test_data_augmentation.py .......                                                                                                                                                                        [ 33%]
test/data_management/test_dataset_building.py ...                                                                                                                                                                             [ 38%]
test/data_management/test_patch_extraction.py ....                                                                                                                                                                            [ 44%]
test/morphometrics/test_compute_morphometrics.py ..............                                                                                                                                                               [ 64%]
test/morphometrics/test_launch_morphometrics_computation.py ..                                                                                                                                                                [ 67%]
test/testing/test_launch_performance_metrics.py .                                                                                                                                                                             [ 69%]
test/testing/test_noise_simulation.py ...                                                                                                                                                                                     [ 73%]
test/testing/test_segmentation_scoring.py ........                                                                                                                                                                            [ 85%]
test/testing/test_statistics_generation.py ^[.^R
...                                                                                                                                                                               [ 91%]
test/visualization/test_generate_axons_from_myelin.py .                                                                                                                                                                       [ 92%]
test/visualization/test_get_masks.py ...                                                                                                                                                                                      [ 97%]
test/visualization/test_merge_masks.py .                                                                                                                                                                                      [ 98%]
test/visualization/test_visualize.py .                                                                                                                                                                                        [100%]

---------- coverage: platform darwin, python 3.6.6-final-0 -----------
Name                                                            Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------------------------
AxonDeepSeg/__init__.py                                             1      0   100%
AxonDeepSeg/ads_utils.py                                           71     40    44%   14-57, 65-91, 110, 126, 153-154, 163-165
AxonDeepSeg/apply_model.py                                        158     17    89%   54-55, 117-137, 206, 209, 212, 230-233, 403
AxonDeepSeg/config_tools.py                                       107      1    99%   137
AxonDeepSeg/data_management/__init__.py                             0      0   100%
AxonDeepSeg/data_management/data_augmentation.py                  141     14    90%   81, 88-91, 97, 104, 110-111, 130, 142-143, 260, 268
AxonDeepSeg/data_management/dataset_building.py                   115      4    97%   225-228
AxonDeepSeg/data_management/input_data.py                         191     44    77%   27, 70-74, 109-114, 178, 198, 211-241, 315-316, 354-355, 373-392, 409, 423
AxonDeepSeg/data_management/patch_extraction.py                    40      5    88%   16-18, 44-45
AxonDeepSeg/integrity_test.py                                      36      4    89%   33, 62-66
AxonDeepSeg/mapping_results.py                                     29     29     0%   4-60
AxonDeepSeg/models/__init__.py                                      0      0   100%
AxonDeepSeg/morphometrics/__init__.py                               0      0   100%
AxonDeepSeg/morphometrics/compute_morphometrics.py                 98      0   100%
AxonDeepSeg/morphometrics/launch_morphometrics_computation.py      26      0   100%
AxonDeepSeg/network_construction.py                                78      8    90%   38, 64, 81-95
AxonDeepSeg/patch_management_tools.py                              63      3    95%   27-30
AxonDeepSeg/segment.py                                            109     38    65%   67, 93, 133, 171-176, 229-314, 318
AxonDeepSeg/testing/__init__.py                                     0      0   100%
AxonDeepSeg/testing/launch_performance_metrics.py                  26      0   100%
AxonDeepSeg/testing/noise_simulation.py                            29      0   100%
AxonDeepSeg/testing/segmentation_scoring.py                       150      5    97%   12-14, 151, 265
AxonDeepSeg/testing/statistics_generation.py                      209     60    71%   106-109, 164-167, 246-248, 315-319, 387-411, 415-431, 443-463, 466
AxonDeepSeg/train_network.py                                      297     57    81%   38, 70, 132, 138, 149, 176, 285, 328-336, 346, 376-380, 394, 416-419, 462-467, 501-503, 540-569, 627-644, 648
AxonDeepSeg/train_network_tools.py                                 49      3    94%   23-24, 60
AxonDeepSeg/trainingforhelios.py                                   26     26     0%   5-49
AxonDeepSeg/visualization/__init__.py                               0      0   100%
AxonDeepSeg/visualization/generate_axons_from_myelin.py            17      0   100%
AxonDeepSeg/visualization/get_masks.py                             28      0   100%
AxonDeepSeg/visualization/merge_masks.py                           11      0   100%
AxonDeepSeg/visualization/visualize.py                            120     83    31%   7-9, 65-151, 166-174, 187-188, 192-200
---------------------------------------------------------------------------------------------
TOTAL                                                            2225    441    80%


========================================================================================================= warnings summary ==========================================================================================================
test/data_management/test_data_augmentation.py::TestCore::()::test_large_max_rescaling_factor_returns_different_image
  /Users/oubou_admin/miniconda3/envs/ads36_venv_conda/lib/python3.6/site-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
    warn("The default mode, 'constant', will be changed to 'reflect' in "

test/data_management/test_dataset_building.py::TestCore::()::test_raw_img_to_patches_creates_expected_folders_and_files
  /Users/oubou_admin/miniconda3/envs/ads36_venv_conda/lib/python3.6/site-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
    warn("The default mode, 'constant', will be changed to 'reflect' in "

test/data_management/test_dataset_building.py::TestCore::()::test_patched_to_dataset_fake_mixed_dataset_creates_expected_dir
  /Users/oubou_admin/miniconda3/envs/ads36_venv_conda/lib/python3.6/site-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
    warn("The default mode, 'constant', will be changed to 'reflect' in "

test/visualization/test_visualize.py::TestCore::()::test_visualize_training_runs_successfully
  /Users/oubou_admin/miniconda3/envs/ads36_venv_conda/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py:107: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
    warnings.warn(message, mplDeprecation, stacklevel=1)

-- Docs: http://doc.pytest.org/en/latest/warnings.html
============================================================================================== 68 passed, 4 warnings in 296.98 seconds ==============================================================================================
): /job:localhost/replica:0/task:0/device:CPU:0
save/SaveV2/tensor_names: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/SaveV2/shape_and_slices: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/RestoreV2/tensor_names: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/RestoreV2/shape_and_slices: (Const): /job:localhost/replica:0/task:0/device:CPU:0


@mathieuboudreau
Copy link
Member Author

I'll update the installation documentation with some Anaconda instructions for how to create virtual environments with a specified version of python.

There's also a way to do so with the native virtualenv venv call, however it's messier (you need to specify the folder location of the other installed python compiler that you want to use): https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv/39713544#39713544

@mathieuboudreau
Copy link
Member Author

@alexfoias have you had the chance to do what Julien requested a while back – create a virtual environment running Python 3.6 on a Windows machine and test this branch (ads36) after installation (pip install -e .) using the command py.test --cov AxonDeepSeg/ --cov-report term-missing?

@alexfoias
Copy link
Contributor

@mathieuboudreau sorry I missed that one. I will do it right away & I will keep you posted.

@mathieuboudreau
Copy link
Member Author

@alexfoias No worries – thanks! Let me know if you run into any issues.

@alexfoias
Copy link
Contributor

@mathieuboudreau why did you recommend to use a virtualenv for python ? Aren't native python 3.6 with pip & git installed enough ?

@alexfoias
Copy link
Contributor

here is the output of the test:

` (ads_python36) C:\Users\neuropoly\ads_test\axondeepseg>py.test --cov AxonDeepSeg/ --cov-report term-missing
============================= test session starts =============================
platform win32 -- Python 3.6.5, pytest-3.5.0, py-1.6.0, pluggy-0.6.0
rootdir: C:\Users\neuropoly\ads_test\axondeepseg, inifile:
plugins: cov-2.5.1
collected 68 items

test\test_config_tools.py ......... [ 13%]
test\test_integrity_test.py . [ 14%]
test\test_segment.py ..... [ 22%]
test\test_train_network.py . [ 23%]
test\data_management\test_data_augmentation.py ....... [ 33%]
test\data_management\test_dataset_building.py ... [ 38%]
test\data_management\test_patch_extraction.py .... [ 44%]
test\morphometrics\test_compute_morphometrics.py .............. [ 64%]
test\morphometrics\test_launch_morphometrics_computation.py .. [ 67%]
test\testing\test_launch_performance_metrics.py . [ 69%]
test\testing\test_noise_simulation.py ... [ 73%]
test\testing\test_segmentation_scoring.py ........ [ 85%]
test\testing\test_statistics_generation.py .... [ 91%]
test\visualization\test_generate_axons_from_myelin.py . [ 92%]
test\visualization\test_get_masks.py ... [ 97%]
test\visualization\test_merge_masks.py . [ 98%]
test\visualization\test_visualize.py . [100%]

----------- coverage: platform win32, python 3.6.5-final-0 -----------
Name Stmts Miss Cover Missing

AxonDeepSeg_init_.py 1 0 100%
AxonDeepSeg\ads_utils.py 71 35 51% 14-57, 70-74, 79, 110, 142-154, 162-167
AxonDeepSeg\apply_model.py 158 17 89% 54-55, 117-137, 206, 209, 212, 230-233, 403
AxonDeepSeg\config_tools.py 107 1 99% 137
AxonDeepSeg\data_management_init_.py 0 0 100%
AxonDeepSeg\data_management\data_augmentation.py 141 15 89% 81, 88-91, 97, 104, 110-111, 130, 142-143, 240, 260, 268
AxonDeepSeg\data_management\dataset_building.py 115 4 97% 225-228
AxonDeepSeg\data_management\input_data.py 191 44 77% 27, 70-74, 109-114, 178, 198, 211-241, 315-316, 354-355, 373-392, 409, 423
AxonDeepSeg\data_management\patch_extraction.py 40 5 88% 16-18, 44-45
AxonDeepSeg\integrity_test.py 36 4 89% 33, 62-66
AxonDeepSeg\mapping_results.py 29 29 0% 4-60
AxonDeepSeg\models_init_.py 0 0 100%
AxonDeepSeg\morphometrics_init_.py 0 0 100%
AxonDeepSeg\morphometrics\compute_morphometrics.py 98 2 98% 13-14
AxonDeepSeg\morphometrics\launch_morphometrics_computation.py 26 2 92% 9-10
AxonDeepSeg\network_construction.py 78 8 90% 38, 64, 81-95
AxonDeepSeg\patch_management_tools.py 63 3 95% 27-30
AxonDeepSeg\segment.py 109 38 65% 67, 93, 133, 171-176, 229-314, 318
AxonDeepSeg\testing_init_.py 0 0 100%
AxonDeepSeg\testing\launch_performance_metrics.py 26 0 100%
AxonDeepSeg\testing\noise_simulation.py 29 0 100%
AxonDeepSeg\testing\segmentation_scoring.py 150 5 97% 12-14, 151, 265
AxonDeepSeg\testing\statistics_generation.py 209 60 71% 106-109, 164-167, 246-248, 315-319, 387-411, 415-431, 443-463, 466
AxonDeepSeg\train_network.py 297 57 81% 38, 70, 132, 138, 149, 176, 285, 328-336, 346, 376-380, 394, 416-419, 462-467, 501-503, 540-569, 627-644, 648
AxonDeepSeg\train_network_tools.py 49 3 94% 23-24, 60
AxonDeepSeg\trainingforhelios.py 26 26 0% 5-49
AxonDeepSeg\visualization_init_.py 0 0 100%
AxonDeepSeg\visualization\generate_axons_from_myelin.py 17 0 100%
AxonDeepSeg\visualization\get_masks.py 28 0 100%
AxonDeepSeg\visualization\merge_masks.py 11 0 100%
AxonDeepSeg\visualization\visualize.py 120 83 31% 7-9, 65-151, 166-174, 187-188, 192-200

TOTAL 2225 441 80%

============================== warnings summary ===============================
test/data_management/test_data_augmentation.py::TestCore::()::test_large_max_rescaling_factor_returns_different_image
c:\users\neuropoly\envs\ads_python36\lib\site-packages\skimage\transform_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "

test/data_management/test_dataset_building.py::TestCore::()::test_raw_img_to_patches_creates_expected_folders_and_files
c:\users\neuropoly\envs\ads_python36\lib\site-packages\skimage\transform_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "

test/data_management/test_dataset_building.py::TestCore::()::test_patched_to_dataset_fake_mixed_dataset_creates_expected_dir
c:\users\neuropoly\envs\ads_python36\lib\site-packages\skimage\transform_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "

test/visualization/test_visualize.py::TestCore::()::test_visualize_training_runs_successfully
c:\users\neuropoly\envs\ads_python36\lib\site-packages\matplotlib\cbook\deprecation.py:107: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
warnings.warn(message, mplDeprecation, stacklevel=1)

-- Docs: http://doc.pytest.org/en/latest/warnings.html
=================== 68 passed, 4 warnings in 365.06 seconds ===================
): /job:localhost/replica:0/task:0/device:CPU:0
save/SaveV2/tensor_names: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/SaveV2/shape_and_slices: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/RestoreV2/tensor_names: (Const): /job:localhost/replica:0/task:0/device:CPU:0
save/RestoreV2/shape_and_slices: (Const): /job:localhost/replica:0/task:0/device:CPU:0 `

@mathieuboudreau
Copy link
Member Author

@alexfoias We've always had installation instructions for ADS that include virtual environments. It's "cleaner" to use different virtual environments for different python softwares, as the package version requirements (see here) can (do) differ between them. If you were using python to develop other software, then installed the ADS requirements on the "default" python environment, package versions (e.g. tensorflow, numpy, etc) would all change from what you were using before, causing you a giant headache and likely "breaking" your old code 😅

I personally prefer creating virtual environments with Anaconda's conda command, as it also allows me to specify the python version (2.7, 3.5, 3.6, 3.7, etc) that I want (or is needed) for that specific software. I updated the documentation for that in this branch, which can be viewed here: https://axondeepseg.readthedocs.io/en/ads36/documentation.html#installation

@mathieuboudreau
Copy link
Member Author

@alexfoias Excellent - thanks!

@oumayb
Copy link
Contributor

oumayb commented Sep 7, 2018

@mathieuboudreau I ran two identical trainings, one with the 2.7 version and the other with the 3.6 version, and it was a success, the results were very similar!
I'm approving the PR!

oumayb
oumayb previously approved these changes Sep 7, 2018
@mathieuboudreau
Copy link
Member Author

@oumayb I just did some final minor changes (increased version number, updated release date). Could you quickly approve again?

@mathieuboudreau mathieuboudreau changed the title ADS move to Python 3.6 Move to Python 3.6 compatibility Sep 11, 2018
@mathieuboudreau mathieuboudreau merged commit 49795de into master Sep 11, 2018
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

Successfully merging this pull request may close these issues.

None yet

5 participants