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

Fix TypeError when torch.jit.load is passed a pathlib.Path #45825

Conversation

jonathan-conder-sm
Copy link
Contributor

Fixes #45824

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Oct 4, 2020
Copy link
Contributor

@gmagogsfm gmagogsfm left a comment

Choose a reason for hiding this comment

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

Could you add a test case for this? Thank you

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #45825 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #45825   +/-   ##
=======================================
  Coverage   68.32%   68.32%           
=======================================
  Files         410      410           
  Lines       52978    52978           
=======================================
+ Hits        36195    36196    +1     
+ Misses      16783    16782    -1     
Impacted Files Coverage Δ
torch/jit/_script.py 91.40% <100.00%> (ø)
torch/jit/_serialization.py 85.71% <100.00%> (ø)
torch/testing/_internal/expecttest.py 78.57% <0.00%> (+1.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1ff46b...de35bcd. Read the comment docs.

@jonathan-conder-sm
Copy link
Contributor Author

Turns out torch.jit.save didn't work either. I fixed that & added a test for both methods

Copy link
Contributor

@gmagogsfm gmagogsfm left a comment

Choose a reason for hiding this comment

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

Looks good, please fix python lint. Let me know when it is ready, and I will commit for you.

@@ -478,13 +478,13 @@ def code_with_constants(self):
r = self.forward.code_with_constants
return (r[0], ConstMap(r[1]))

def save(self, f, _extra_files={}):
def save(self, f, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

OOC, why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lint error was because I was passing a mutable object (i.e. {}) as a default argument. Alternative solution would be to have None as the default with

if _extra_files is None:
    _extra_files = {}

inside the function. But before I made any changes the function was already using kwargs so I figured I'd just switch back to that.

@jonathan-conder-sm
Copy link
Contributor Author

Think it's ready now. Thanks!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@gmagogsfm merged this pull request in 9dc9a55.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged oncall: jit Add this issue/PR to JIT oncall triage queue open source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

torch.jit.load does not accept pathlib.Path arguments
4 participants