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

Cmdline ar resolver #165

Merged
merged 3 commits into from
Jan 29, 2018

Conversation

pmolodo
Copy link
Contributor

@pmolodo pmolodo commented Feb 22, 2017

Description of Change(s)

Fixes to allow usage of unresolved asset paths with both the command-line tools and the katana plugin

Included Commit(s)

Fixes Issue(s)

None previously reported (that I know of...)

Copy link
Contributor

@sunyab sunyab left a comment

Choose a reason for hiding this comment

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

Hey @elrond79, I had a couple of notes and questions down below. Thanks!

# Sdf.Layer.FindOrOpen first
args = []
for arg in origArgs:
layer = Sdf.Layer.FindOrOpen(arg)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would break usddiff in the case where you pass in directories to compare, since args (and origArgs) would contain directory names. You would wind up calling Sdf.Layer.FindOrOpen on a directory, which would fail and result in a ValueError getting raised.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my response to the comment above...

origArgs = args

# path may not be a "real" path due to custom resolvers... so use
# Sdf.Layer.FindOrOpen first
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned about the performance impact of using Sdf.Layer.FindOrOpen to try to deal with custom asset paths that may not have a corresponding file on the filesystem. It seems like we don't really care about loading the layer here, we just want to know whether a layer at that path actually exists. So instead of doing this, could we try to use Ar.Resolver.Resolve somehow to give us this information?

Copy link
Contributor Author

@pmolodo pmolodo Mar 11, 2017

Choose a reason for hiding this comment

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

Hmm, good point. Essentially want we want to do here is just validate using the ArResolver. I actually posted a question on the mailing list about this (and some other resolver issues) - see the third question here: https://groups.google.com/forum/#!topic/usd-interest/E3huSatYrLI

Assuming that we can rely on getting back an empty string as a form of validation, I think maybe the best thing to do is to just replace the look that checks for existence with one which checks that either it resolves to non-empty, OR it's a dir (per your next note).

UsdStageRefPtr const& stage = UsdStage::Open(rootLayer, sessionLayer,
ArGetResolver().GetCurrentContext(),
UsdStageRefPtr const& stage = UsdStage::Open(rootLayer, sessionLayer,
ArGetResolver().CreateDefaultContextForAsset(fileName),
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the reason for changing this to use a new context rather than whatever context was currently bound?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, just confusion about best practices - see my first question here: https://groups.google.com/forum/#!topic/usd-interest/E3huSatYrLI

Going off of some other examples (ie, usdviewq/mainWindow.py, and _createPathResolverContext), it seemed like the "best" thing to do was, if you knew the path you were about to open, to create a context for it. Apologies if this isn't the proper thing to do - I will remove this change!

// absolute paths
std::string expandedPath = mayaFile.expandedFullName().asChar();
ArResolver& resolver = ArGetResolver();
resolver.ConfigureResolverForAsset(expandedPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should reconfigure the resolver here, since that's a stateful change that potentially affects all subsequent consumers of ArResolver for path resolution. Can you describe what issue you were running into here?

Copy link
Contributor Author

@pmolodo pmolodo Mar 11, 2017

Choose a reason for hiding this comment

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

Again, just confusion about best practices.

Your comment about this being a stateful change helps clarify things somewhat, though - on re-reviewing the existing code, it seems like everywhere that's calling ConfigureResolverForAsset is doing so from within "application level" code. I'll remove that line.

@pmolodo
Copy link
Contributor Author

pmolodo commented Mar 11, 2017

First - thanks for the code review, was very helpful!

Second - I'm making the changes noted... and realizing that using on-disk filepaths and unresolved asset paths interchangeably is tricky, once directories get involved. For simplicity, I'm going to make the following assumptions:

  • we first check an arg to see if it is a file/dir, and if so, assume it is NOT an unresolved asset path
  • if any of the directory forms are used, then none of the other args may be unresolved asset paths

I'll add a note to the parser help to this effect. Let me know if you'd rather proceed in a different manner.

@sambvfx sambvfx force-pushed the cmdline_ArResolver branch 2 times, most recently from 8f6c5be to 191720a Compare March 15, 2017 01:38
@pmolodo pmolodo force-pushed the cmdline_ArResolver branch from 191720a to d4a74d5 Compare March 15, 2017 02:24
@pmolodo
Copy link
Contributor Author

pmolodo commented Mar 15, 2017

So, I pushed a fresh branch where I've made the changes requested. Sorry for the delay - we're in the middle of migrating our commits over to topgit to make juggling our various patches more manageable. Anyway, this branch is a "clean" history - if you want to see all the incremental changes, I can push the topgit patch branches. Thanks again for the review!

@pmolodo
Copy link
Contributor Author

pmolodo commented May 4, 2017

Pushed a new version that fixed a test failure...

formerly failed testUsdDiffToolVariousFormats4 + 5 - _getFileFormat wasn't returning None for unrecognized file formats

@jtran56
Copy link

jtran56 commented Jun 2, 2017

Filed as internal issue #147131.

@sunyab
Copy link
Contributor

sunyab commented Jun 13, 2017

Hi @elrond79, I was trying to merge this in but I still run into a test failure with testUsdDiffToolVariousFormats5:

Traceback (most recent call last):
File "/scratch/build_local/dev/src/inst/fedora-gcc64-opt/pxr/bin/usddiff", line 340, in
main()
File "/scratch/build_local/dev/src/inst/fedora-gcc64-opt/pxr/bin/usddiff", line 324, in main
results.flatten, results.noeffect):
File "/scratch/build_local/dev/src/inst/fedora-gcc64-opt/pxr/bin/usddiff", line 152, in _runDiff
baselineFileType = _getFileFormat(baseline)
File "/scratch/build_local/dev/src/inst/fedora-gcc64-opt/pxr/bin/usddiff", line 117, in _getFileFormat
return fileFormat.formatId
AttributeError: 'NoneType' object has no attribute 'formatId'

Do you guys see the same thing? Or is this something on my end?

@pmolodo pmolodo force-pushed the cmdline_ArResolver branch from d4a74d5 to dd7f456 Compare June 13, 2017 21:57
@pmolodo
Copy link
Contributor Author

pmolodo commented Jun 13, 2017

Oops - sorry, yes, that is a problem we saw, and fixed a while ago... but apparently forgot to push a refreshed PR. The PR should be up-to-date now.

For your reference, here's the (non-collapsed) commit that fixed this:

LumaPictures@2f05bd7

ie, can now do "usdview custom://asset_bigGuy/costume_red/version_0023" (assuming you have a custom ArResolver to handle "custom://" paths)

usdview, usdcat, usdcheck, and usddiff should now all work with unresolved paths; usdstitch already worked

usdstitchclips and usdGenSchema are untested, due to not having appropriate inputs on hand; usdrender is untested, due to not having a OpenGL.raw._GLX module
@pmolodo
Copy link
Contributor Author

pmolodo commented Nov 16, 2017

Rebased the PR to resolve merge conflicts...

@pixar-oss pixar-oss merged commit fdb3a78 into PixarAnimationStudios:dev Jan 29, 2018
pixar-oss added a commit that referenced this pull request Jan 29, 2018
@pmolodo pmolodo deleted the cmdline_ArResolver branch March 12, 2019 23:02
AdamFelt pushed a commit to autodesk-forks/USD that referenced this pull request Apr 16, 2024
…fix_frameRecorder_failure

OGSMOD-2625: Fix test case "testUsdAppUtilsFrameRecorder" failure
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.

4 participants