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

GeometryFactoryPath lookup should be more consistent with other preloader utilities. #9493

Merged
merged 6 commits into from
Feb 20, 2019

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Feb 16, 2019

Purpose

Provide a more tolerant GeometryFactoryPath lookup method that falls back to other libG/ASM version combinations that are <= to the major version requested.

  • adds tests for invalid/valid inputs of the new method.
  • slightly modifies existing summaries to be more explicit on existing non tolerant methods.

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

Reviewers

@QilongTang @scottmitchell

FYIs

@aparajit-pratap

should harden / define edge cases and add tests next
define edge cases
@mjkkirschner mjkkirschner changed the title Lib g tolerant GeometryFactoryPath lookup should be more consistent with other preloader utilities. Feb 16, 2019


//when passed a null version this method should return empty string - as the geometry path was not located
Assert.AreEqual(string.Empty,
Copy link
Member Author

Choose a reason for hiding this comment

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

please see these cases - looking for feedback if these make sense.

@mjkkirschner mjkkirschner added the PTAL Please Take A Look 👀 label Feb 16, 2019
public static string GetGeometryFactoryPathTolerant(string rootFolder, Version tolerantVersion){
if(tolerantVersion != null && rootFolder != null)
{
return Path.Combine(Utilities.GetLibGPreloaderLocation(tolerantVersion, rootFolder), Utilities.GeometryFactoryAssembly);
Copy link
Contributor

@QilongTang QilongTang Feb 17, 2019

Choose a reason for hiding this comment

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

The code itself looks fine but I was expecting us to merge some code between GetGeometryFactoryPath2 and GetGeometryFactoryPathTolerant because in the end either DynamoCore or our client would only be available to call one of them. But for now the code path between these two are quite different. From the API name I would assume this one is only doing the fall back logic as addition? Do you think if we also still need those folder check logic in this new API?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. I find these two methods both potentially useful - they do different things, and I think it's always useful to have an explicit method to avoid unknown behavior which is why I did not obsolete the other method.

  2. Sandbox AFAIK does not call these methods at all.

  3. The end result to the client is like you said that it appears it does a fallback - it DOES have different edge case behavior though - it returns a empty string instead of exceptions when it encounters bad input - that's kind of what I was asking about in the test cases? I'm okay with the more slow failure because this is a tolerant version of the method, but open to other opinions for sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I don't mean to obsolete the other one. I thought we want to include the folder check logic in the new API as well because of some legacy bug, if you think it is OK and good enough for the clients then this version should be fine to use. Do you plan to make any change in client code as an example usage of this API later when nuget is up?

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually don't see any reason to keep GetGeometryFactoryPath2 after the addition of this new API and I think we should add the folder check exceptions to the new API. I don't see reasons to remove them from here. GetGeometryFactoryPath2 can give unexpected results (in combination with other API's) like we've seen in the Revit case so I think it should be obsoleted.

@mjkkirschner
Copy link
Member Author

mjkkirschner commented Feb 18, 2019

Thanks for the feedback @QilongTang and @aparajit-pratap - I will take another crack at reconciling these apis tomorrow.

add exception throwing for null or bad inputs
define expected outputs in tests
@mjkkirschner
Copy link
Member Author

mjkkirschner commented Feb 20, 2019

@QilongTang @aparajit-pratap @scottmitchell - went through this again and after it seems to avoid adding any new APIs we can just make the existing GetGeometryFactoryPath2 method fallback, and keep all the null and directory existing checks.

Clients should not need to update their usage but they will get more robust behavior.

The tests have been updated to verify the edge cases with bad inputs and the comments have been updated for all methods that wrap this method internally.

@aparajit-pratap
Copy link
Contributor

@mjkkirschner excellent tests! Thanks, LGTM!

@aparajit-pratap aparajit-pratap added the LGTM Looks good to me label Feb 20, 2019
var rootFolder = Path.Combine(Path.GetTempPath(), "LibGTest");
// both versions of libG exist
var libG22500path = System.IO.Directory.CreateDirectory(Path.Combine(rootFolder, "LibG_225_0_0"));
var libGTestPath = new DirectoryInfo(Path.Combine(rootFolder, "LibG_224_24_24"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

You end up not using this, right? Also, the "both versions of libG exist" comment in this test threw me off as I was reading through it.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks @scottmitchell will fix this.

}

//lookup libG with a fallback to older versions which share the major version number.
var libGFolder = Utilities.GetLibGPreloaderLocation(version, rootFolder);
Copy link
Contributor

Choose a reason for hiding this comment

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

With the current implementation of GetGeometryFactoryPath2 I feel that we can remove the preloadASM() function in D4R since the default call of GetGeometryFactoryPath will make the fall back as well, what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I think their implementation can go back to how it was previously.

@QilongTang
Copy link
Contributor

The current implementation makes sense to me in a way that it is very clear to a client which API to use. LGTM

@mjkkirschner mjkkirschner removed the PTAL Please Take A Look 👀 label Feb 20, 2019
@scottmitchell
Copy link
Collaborator

LGTM!

@mjkkirschner mjkkirschner merged commit 5bbdfa1 into DynamoDS:master Feb 20, 2019
@mjkkirschner
Copy link
Member Author

@QilongTang @AndyDu1985 @ZiyunShang - verified this fixes the issue loading ASM on on latest revit build - I confirmed this by moving back before this PR:
DynamoDS/DynamoRevit#2342

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LGTM Looks good to me
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants