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

Open usdview without specifying a file #3321

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

MishDivyAmzn
Copy link

Running usdview without usdFile positional argument will now open an empty stage. If usdFile is passed, then there will be no behavior change.

Description of Change(s)

  • Made usdFile positional argement Optional
  • Updated the GetResolverContext method to return a default context when usdFile is not passed.
  • Updated the appController _openStage method to create an empty stage when usdFilePath is a falsy value.
  • Updated the _saveFlattendedAs, _saveOverridesAs and _saveViewerImage methods to use "new_scene" prefix for recommended file name when usdFile is a falsy value.

Note: Prior to this change, running usdview without usdFile argument would print error: the following arguments are required: usdFile.

Fixes Issue(s)

#3093

  • I have verified that all unit tests pass with the proposed changes
  • I have submitted a signed Contributor License Agreement

@MishDivyAmzn
Copy link
Author

Requested a signed CLA from my employer. Will send the CLA to Pixar and update this PR as soon as I receive the CLA.

@jesschimein
Copy link
Contributor

Filed as internal issue #USD-10199

❗ Please make sure that a signed CLA has been submitted!

@jesschimein
Copy link
Contributor

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@spiffmon spiffmon left a comment

Choose a reason for hiding this comment

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

Just one suggestion, though others may have feedback also - thanks!

def _getRecommendedFilenamePrefix(self):
return (self._parserData.usdFile.rsplit('.', 1)[0]
if self._parserData.usdFile
else 'new_file')
Copy link
Member

Choose a reason for hiding this comment

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

Should this be something unique, like when we are creating temp files? It's probably unlikely, but if a bunch of "file-less" usdview's are launched and you do live-editing and want to save out the overrides from more than one, if you go with the recommendation you'll stomp your results. OTOH, you will see that the suggestion is the same for both, and have the ability to change it. Just a thought to consider.

Copy link
Member

Choose a reason for hiding this comment

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

... if you do go that route, given that there's multiple uses of this recommended name, and only one "empty/new stage" per usdview, Seems like we would want just one unique name per-process, right?

Copy link
Author

@MishDivyAmzn MishDivyAmzn Sep 28, 2024

Choose a reason for hiding this comment

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

Good point! The unique names usually look a bit ugly to people, so I wasn't sure about it :). I can replace this function with the following if people think this would be better.

def _getRecommendedFilenamePrefix(self):
    return (self._parserData.usdFile.rsplit('.', 1)[0]
            if self._parserData.usdFile
            else f'new_file_{os.getpid()}_{datetime.now().strftime("%Y%m%d_%H%M%S_%f")[:18]}')

The above function would make a unique name suggestion based on process ID and current datetime (millisecond precision), so almost unique everytime. But could be a bit jarring to look at. Open to suggestions :)

Here's an example of a potential suggestion from the above function:
new_file_12345_20240927_154510_12

We can potentially remove the datetime portion if we just need a unique name per process ID.

Thanks for the feedback, lmk if anything else stands out.

@anwang2009
Copy link
Contributor

Hi @MishDivyAmzn, thanks for the PR! Any updates on the CLA?

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