-
Notifications
You must be signed in to change notification settings - Fork 638
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
Provide a strategy for host integrator's to set the python template at startup #9533
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3c8bb1a
provide a strategy for host integrators to set Python node template a…
alfarok 301aeb1
use 'is' as opposed to 'try/catch'
alfarok 7681b36
Fix several bugs around previously existing logging statements
alfarok 96aba95
add unit tests verifying valid and invalid API usage
alfarok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done because the
DynamoModel
constructor takes aIStartConfiguration
config as its only param. I believe modifying the interface (even adding a new property) would be an API breaking change, but feel free to correct me if I am wrong on this or there is a better strategy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should do something like:
defaultConfig = config as DefaultStartConfiguration
and then check for null because it's possible that the concreteType is NOT a DefaultStartConfiguration ... and that needs to be handled. (ie missing the python template field you just added)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively you can add a second interface and check if the object implements that interface, if it does - do the right thing and set the path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Same options in https://jira.autodesk.com/browse/DYN-1644
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general, I don't think casting like this is a great idea for the problem we are discussing as casting can throw -
as
andis
should not.https://docs.microsoft.com/en-us/dotnet/api/system.invalidcastexception?view=netframework-4.7.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback guys. I was not happy with this approach either but
as
cannot be used with a non-nullable value type whichDefaultStartConfiguration
is as a struct. This is why I wrapped this logic in a try/catch returning the default template if an exception is thrown. However, performing a check such asis possible but does not guaranteed the PythonTemplatePath has been set. Attempting to retrieve the
PythonTemplatePath
property will simply return null if it was not set and I verify this is not the case below before proceeding. Long story short we can probably useis
to verify theconfig
is of theDefaultStartConfiguration
type or of a type that inherits from it. I don't think adding another struct is necessary just for this property. If theconfig
is of another type we return the default template. I believe the try/catch can also be removed withis
as @mjkkirschner suggested since it will not throw. What do you guys think about this approach? @QilongTangThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me.