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

Allow pkgs to partially load if some of the assemblies are good #12763

Merged
merged 7 commits into from
Apr 11, 2022

Conversation

pinzart90
Copy link
Contributor

@pinzart90 pinzart90 commented Apr 1, 2022

Purpose

Allow PackageLoader to partially load packages (only those assemblies that can be loaded should be loaded)
Original issue tracked here https://forum.dynamobim.com/t/cant-seem-to-install-packages-on-dynamo-sandbox/75000/12

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Release Notes

(FILL ME IN) Brief description of the fix / enhancement. Mandatory section

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@pinzart90 pinzart90 requested a review from mjkkirschner April 1, 2022 18:18
bool nodeModelOrNodeView;
try
{
nodeModelOrNodeView = !NodeModelAssemblyLoader.ContainsNodeModelSubType(assem)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These checks (ex ContainsNodeModelSubType) actually iterate over all the types in the assembly...so in the case of RhythmRevit.dll....it would throw a ReflectionTypeLoadException exception

&& !(NodeModelAssemblyLoader.ContainsNodeViewCustomizationType(assem));
}
catch (Exception ex) {
throw new Exceptions.LibraryLoadFailedException(assem.Location, ex.Message);
Copy link
Contributor Author

@pinzart90 pinzart90 Apr 1, 2022

Choose a reason for hiding this comment

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

any other type of Exception would disrupt the package loading operation.
Exceptions are managed in the same way inside LibraryServices.LoadNodeLibrary, i.e LibraryLoadFailedException usually means you can continue, anything else is fatal to the loading op

@pinzart90 pinzart90 marked this pull request as ready for review April 5, 2022 13:10
Copy link
Contributor

@sm6srw sm6srw left a comment

Choose a reason for hiding this comment

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

LGTM!

if (loadedNodeLibs.Count > 0)
{
// Try to load any valid node libraries regardless package state
PackagesLoaded?.Invoke(loadedNodeLibs);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you change the sequence of loading this by moving it up here from line 290?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so that I do not have to add it in 2 places (when it succeeds and in the catch blocks)

Copy link
Contributor Author

@pinzart90 pinzart90 Apr 7, 2022

Choose a reason for hiding this comment

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

To avoid code duplication...I can put it here (line 283) or in a finally block (but I would have to tweak the loadedNodeLibs to be declared before the try catch)


if (blockedAssemblies.Count > 0)
{
throw new Exception("The following assemblies are blocked : " + string.Join(", ", blockedAssemblies.Select(x => Path.GetFileName(x.Location))));
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 should be new AssembyBlockedException for it to be caught here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct. Thanks

// Generic fatal error
if (failedNodeLibs.Count > 0)
{
throw new Exception("Failed to load the following assemblies : " + string.Join(", ", failedNodeLibs.Select(x => Path.GetFileName(x.Location))));
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be new LibraryLoadFailedException?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well..it could be..but I don't think it matters...since we do not catch that in any special way in this try catch

@pinzart90 pinzart90 merged commit 632adbc into master Apr 11, 2022
@pinzart90 pinzart90 deleted the partial_pkg_load branch April 11, 2022 16:40
@johnpierson
Copy link
Member

Thank you all for your work on this. I am thrilled to see this as a "feature" rather than a "Random convenience" lol 😁

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.

6 participants