Skip to content

API for libG Preloader Lookup#9324

Merged
QilongTang merged 8 commits intomasterfrom
preloaderlookup
Jan 3, 2019
Merged

API for libG Preloader Lookup#9324
QilongTang merged 8 commits intomasterfrom
preloaderlookup

Conversation

@QilongTang
Copy link
Contributor

@QilongTang QilongTang commented Dec 18, 2018

Please Note:

  1. Before submitting the PR, please review How to Contribute to Dynamo
  2. Dynamo Team will meet 1x a month to review PRs found on Github (Issues will be handled separately)
  3. PRs will be reviewed from oldest to newest
  4. If a reviewed PR requires changes by the owner, the owner of the PR has 30 days to respond. If the PR has seen no activity by the next session, it will be either closed by the team or depending on its utility will be taken over by someone on the team
  5. PRs should use either Dynamo's default PR template or one of these other template options in order to be considered for review.
  6. PRs that do not have one of the Dynamo PR templates completely filled out with all declarations satisfied will not be reviewed by the Dynamo team.
  7. PRs made to the DynamoRevit repo will need to be cherry-picked into all the DynamoRevit Release branches that Dynamo supports. Contributors will be responsible for cherry-picking their reviewed commits to the other branches after a LGTM label is added to the PR.

Purpose

This is an improvement when working with a beta release of ASM release that we make our libG preloader lookup mechanism more tolerant than just search for the exact match.

The influence of this API is that for in-process Dynamo integration, client need to add this API call to their ASM preloading logic:

        internal static Version PreloadAsmFromRevit()
        {
            var asmLocation = AppDomain.CurrentDomain.BaseDirectory;
            Version libGversion = findRevitASMVersion(asmLocation);
            var dynCorePath = DynamoRevitApp.DynamoCorePath;
            var preloaderLocation = DynamoShapeManager.Utilities.GetLibGPreloaderLocation(libGversion, dynCorePath);
            DynamoShapeManager.Utilities.PreloadAsmFromPath(preloaderLocation, asmLocation);
            return libGversion;
        }

Declarations

Check these if you believe they are true

  • The code base 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.
    Running self-CI
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning, and are documented in the API Changes document.

Reviewers

@angelowang @mjkkirschner

FYIs

@aparajit-pratap @alfarok

@QilongTang QilongTang added WIP DNM Do not merge. For PRs. labels Dec 18, 2018
@QilongTang QilongTang added PTAL Please Take A Look 👀 and removed DNM Do not merge. For PRs. WIP labels Dec 19, 2018
@QilongTang QilongTang changed the title [WIP] API for libG Preloader Lookup API for libG Preloader Lookup Dec 19, 2018
@QilongTang
Copy link
Contributor Author

@mjkkirschner @aparajit-pratap @angelowang Thank you guys for the review, I addressed all your comments and this is ready for another look

@QilongTang
Copy link
Contributor Author

@mjkkirschner @aparajit-pratap Ping

preloaderVersions.Reverse();
// Pick the closest preloader version below or use the default value when no libG folder found
var preloaderVersion = preloaderVersions.FirstOrDefault() == null ? version : preloaderVersions.First();
return Path.Combine(rootFolder, string.Format("libg_{0}_{1}_{2}", preloaderVersion.Major, preloaderVersion.Minor, preloaderVersion.Build));
Copy link
Contributor

Choose a reason for hiding this comment

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

If there's no matching libg folder found for the target version passed in, then setting preloaderVersion to version and constructing a libg folder path from it will return a non-existent location.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aparajit-pratap Preload() will fail in this case, do you prefer just fall back to whatever libG folder available even the version is larger?

Copy link
Contributor Author

@QilongTang QilongTang Jan 2, 2019

Choose a reason for hiding this comment

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

@aparajit-pratap
After deeper look of everything together, I think we will end up having invalid path only in two cases:

  1. User only has a libG folder with higher major version
  2. User deleted all the local libG folders

Although unlikely, when these two cases happen, we will throw exception at

throw new ArgumentException("preloadedPath");
which will end up in the analytics data. I have made the exception message more explicit, but at this point DynamoViewModel has not been initialized so there is no crash dialog.

I think it is fine this way because the two cases I mentioned is very less likely to happen unless user touches the Dynamo Installation folder themselves.

@aparajit-pratap
Copy link
Contributor

@QilongTang I just have one more comment; the last one above that I think needs to be addressed. After that this is good to go.

@mjkkirschner
Copy link
Member

@QilongTang @aparajit-pratap is this good to go?

@QilongTang
Copy link
Contributor Author

QilongTang commented Jan 2, 2019

@mjkkirschner Not yet, @aparajit-pratap wanted to add some better error message when libG preloader not found so I am looking into it

@aparajit-pratap
Copy link
Contributor

Thanks @QilongTang, LGTM!

@QilongTang QilongTang merged commit 0b0d90b into master Jan 3, 2019
@QilongTang QilongTang deleted the preloaderlookup branch January 3, 2019 03:55
QilongTang added a commit that referenced this pull request Jan 3, 2019
* Add a new static function for preloader lookup

* Find the cloest version of preloader from ASM version

* Add Unit Test

* Address comments

* Fix null case and regression

* Update Unit test and address comments

* Update exception message
@QilongTang QilongTang removed the PTAL Please Take A Look 👀 label Jan 3, 2019
QilongTang added a commit that referenced this pull request Jan 3, 2019
* Add a new static function for preloader lookup

* Find the cloest version of preloader from ASM version

* Add Unit Test

* Address comments

* Fix null case and regression

* Update Unit test and address comments

* Update exception message
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