cBioPortal / oncotree

Creative Commons Attribution 4.0 International
37 stars 27 forks source link

oncotree_to_oncotree.py should support python3 #233

Closed sheridancbio closed 3 years ago

sheridancbio commented 3 years ago

Co-authored-by: thomasyu888 thomasyu888@gmail.com Co-authored-by: Thomas Yu tyu@ip-10-5-30-58.ec2.internal Co-authored-by: thomas.yu thomas.yu@sagebase.org

sheridancbio commented 3 years ago

208 has been merged to a feature branch to facilitate the running of Jenkins tests. Jenkins unit tests have failed with this message:

21:11:43 Traceback (most recent call last): 21:11:43 File "/data/ben/local/lib/python2.7/unittest/loader.py", line 254, in _find_tests 21:11:43 module = self._get_module_from_name(name) 21:11:43 File "/data/ben/local/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name 21:11:43 import(name) 21:11:43 File "/srv/www/jenkins/jobs/oncotree/workspace/scripts/test/test_oncotree_to_oncotree.py", line 8, in 21:11:43 from oncotree_to_oncotree import * 21:11:43 File "/srv/www/jenkins/jobs/oncotree/workspace/scripts/oncotree_to_oncotree.py", line 56 21:11:43 print("ERROR (HttpStatusCode %d): Unable to retrieve OncoTree versions." % (response.getcode()), file=sys.stderr)

This indicates that we are running python2.7 as an engine for the unit testing on the Jenkins server, and that the unittest module is being used. We need to add python3.0 support on the jenkins server and find/test the appropriate unittest framework module for python3.0

sheridancbio commented 3 years ago

@thomasyu888 : I've updated your changes to run cleanly on our python 3.4 installation. Unit tests are still failing for a different reason, but we will try to work that out today.

Could you download this branch (convert-to-python-3) and test out the updated script on your system / with your version of python and make sure it runs as expected? I assume that code which runs in python 3.4 will also run on python 3.6/3.7... but we should make sure.

thomasyu888 commented 3 years ago

Thanks @sheridancbio, this works on 3.7 and 3.8.

sheridancbio commented 3 years ago

Jenkins has been configured to include python3 in its execution path and tests for the scripts module are now running properly, but a failure is now being observed because some tests are assuming output order of a dictionary key set, which seems to have been altered between python 2.7 and python 3.4: 14:16:43 File "/srv/www/jenkins/jobs/oncotree/workspace/scripts/test/test_oncotree_to_oncotree.py", line 82, in test_resolve_multiple_future_possible_target_oncotree_codes_no_new_children 14:16:43 self.run_resolve_oncotree_codes_test("ALL", set(["BLL", "TLL"]), False, format_oncotree_code_options("ALL", "{BLL,TLL}", 0), False) 14:16:43 File "/srv/www/jenkins/jobs/oncotree/workspace/scripts/test/test_oncotree_to_oncotree.py", line 200, in run_resolve_oncotree_codes_test 14:16:43 self.assertEqual(expected_oncotree_code_option, actual_oncotree_code_option) 14:16:43 AssertionError: 'ALL -> {BLL,TLL}' != 'ALL -> {TLL,BLL}' 14:16:43 - ALL -> {BLL,TLL} 14:16:43 ? ^ ^ 14:16:43 + ALL -> {TLL,BLL} 14:16:43 ? ^ ^

Tests checks need to be altered to compare collections without output order assumptions

sheridancbio commented 3 years ago

Tests checks need to be altered to compare collections without output order assumptions

This has been accomplished by making output order deterministic / sorted.