Python 3 Upgrade#160
Conversation
|
I have looked through the stage 1 fixes applied by futurize and they LGTM, mostly very safe |
victorhuangwq
left a comment
There was a problem hiding this comment.
Tested Tango by grading various assignments through Autolab, and it works as expected.
Overall the changes looks good, and I think this is a good patch (and improvement).
Some minor issues should be addressed before merging, but other than that it should be okay!
| """ poolSize - returns the size of the vmName pool, for external callers | ||
| """ | ||
| if vmName not in self.machines.keys(): | ||
| if vmName not in list(self.machines.keys()): |
There was a problem hiding this comment.
same comment with regards to the key situation in jobqueue
There was a problem hiding this comment.
self.machines here is also either a TangoNativeDictionary or TangoRemoteDictionary
There was a problem hiding this comment.
refer to comment below
|
@victorhuangwq Thanks for your comments! I've rectified the issues you raised, do look at it again when you're available :D |
victorhuangwq
left a comment
There was a problem hiding this comment.
There are still some issues with regards to the usage of TangoRemoteDictionary. Other than that it looks good.
|
|
||
| def keys(self): | ||
| return self.dict.keys() | ||
| return list(self.dict.keys()) |
There was a problem hiding this comment.
doesn't it return a list here?
Wouldn't calling list again on keys() be redundant in the other lines I have highlighted above? Such as in
if vmName not in list(self.machines.keys()):
| def keys(self): | ||
| return self.r.hkeys(self.hash_name) | ||
| keys = map(lambda key : key.decode(), self.r.hkeys(self.hash_name)) | ||
| return list(keys) |
There was a problem hiding this comment.
It seems to be returning a list when keys are called on the TangoRemoteDictionary.
| """ poolSize - returns the size of the vmName pool, for external callers | ||
| """ | ||
| if vmName not in self.machines.keys(): | ||
| if vmName not in list(self.machines.keys()): |
There was a problem hiding this comment.
refer to comment below
|
This should not block the upgrade, since I believe the current code to be correct, but most if not all of the keys() calls in the code do not require the list form of the keys (you only need to listify the keys if you either want to use [] to access elements of the key list, or if you will alter the dict while iterating over the keys). Furthermore, a more readable way to do would be to implement
instead. TangoRemoteDictionary could use HEXISTS to implement |
| tango.log.debug("Resetting Tango VMs") | ||
| tango.resetTango(tango.preallocator.vmms) | ||
| for key in tango.preallocator.machines.keys(): | ||
| for key in list(tango.preallocator.machines.keys()): |
| """ | ||
| self.lock.acquire() | ||
| if vm.name not in self.machines.keys(): | ||
| if vm.name not in list(self.machines.keys()): |
@cg2v This is a great suggestion, I will add it as a future enhancement instead of adding that to this PR to avoid making this PR bigger than it already is. Thank you and really appreciate the spotting of other redundant wrappers of |
victorhuangwq
left a comment
There was a problem hiding this comment.
Testing: Tested Tango3 branch by grading various assignments through Autolab, and it works as expected.
I have verified that:
- Patch from #153 has been applied
- Unnecessary lists, as mentioned by both @cg2v and I, has been removed
- Dockerfile is now back on 18.04 (change removed)
This pull request LGTM :)
|
@fanpu Before you merge in however, please create an alternate Python 2 branch, preferably called At the same time, here are the list of things we should also do alongside this PR. I can help with it as well.
|
I will draft a new release after I merge this to master. I think other TODO items would include update installation instructions on our docs too. |
Plan:
Unfortunately, we have almost no test coverage so regressions must be detected by hand. Our goal is to port Tango to Python 3 while still maintaining Python 2 compatibility.
Tested with all CLI commands given in https://autolab.github.io/docs/tango-cli/
This is now ready for review!