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

Efficiently solve dependency metadata on install #10544

Merged
merged 10 commits into from
Apr 6, 2020

Conversation

mmisol
Copy link
Collaborator

@mmisol mmisol commented Apr 6, 2020

Purpose

When resolving dependencies from the workspace dependency extension,
the entire metadata of dependent packages was requested. However, only
information about the version was truly needed, and for packages with a
lot of versions this was causing latency issues.

Now only the package version of dependencies is obtained. As a result,
several code changes were needed, as part of the code path is shared
with the standard installation of packages through search, but with
different data requirements in each case. Several properties and
functions no longer used were marked as 'Obsolete'.

Added some basic unit tests for the new functions in package manager
client.

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.

Reviewers

@mjkkirschner @zeusongit

FYIs

@reddyashish

@@ -2233,6 +2229,10 @@ Uninstall the following packages: {0}?</value>
<data name="DynamoViewSettingsMenuShowCodeBlockNodeLineNumber" xml:space="preserve">
<value>Show CodeBlockNode Line Numbers</value>
</data>
<data name="MessageFailedToDownloadPackageVersion" xml:space="preserve">
<value>Failed to download version {0} of package with id: {1}. Please try again and report the package if you continue to have problems.</value>
<comment>Message box content. {0} = 1.2.3, {1} = 57d576e8f615e7725800001d</comment>
Copy link
Member

Choose a reason for hiding this comment

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

are these default values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, just examples of what kind of text is expected in the placeholders. I thought that's a good way of communicating that to whoever does the text translations.

@@ -701,7 +704,7 @@ internal void DownloadAndInstall(PackageDownloadHandle packageDownloadHandle, st
Package dynPkg;

var pmExtension = DynamoViewModel.Model.GetPackageManagerExtension();
var firstOrDefault = pmExtension.PackageLoader.LocalPackages.FirstOrDefault(pkg => pkg.Name == packageDownloadHandle.Name);
var firstOrDefault = pmExtension.PackageLoader.LocalPackages.FirstOrDefault(pkg => pkg.ID == packageDownloadHandle.Id);
Copy link
Member

Choose a reason for hiding this comment

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

hmm, do you think this could change any existing behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so. I tested installing packages from both the search and the workspace dependency extension to be sure.

@@ -721,18 +724,13 @@ internal void DownloadAndInstall(PackageDownloadHandle packageDownloadHandle, st

if (packageDownloadHandle.Extract(DynamoViewModel.Model, downloadPath, out dynPkg))
{
var p = Package.FromDirectory(dynPkg.RootDirectory, DynamoViewModel.Model.Logger);
Copy link
Member

Choose a reason for hiding this comment

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

why is this no longer required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was already being done inside packageDownloadHandle.Extract, but only for the workspace dependency extension code path. I unified both code paths and now it's always done inside Extract, which returns a boolean to report success.

@mjkkirschner
Copy link
Member

@mmisol looks good to me!

x => x.Item2.contents.Contains(PackageManagerClient.PackageContainsPythonScriptsConstant));
var containsBinariesOrPythonScripts = dependencyVersionHeaders.Any(x =>
x.contents.Contains(PackageManagerClient.PackageContainsBinariesConstant) ||
x.contains_binaries ||
Copy link
Contributor

Choose a reason for hiding this comment

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

We would get some minor performance gains by moving the contains_binaries test before the Contains() check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree

}
}

/// <summary>
/// Returns a newline delimited string representing the package name and version of the argument
/// </summary>
[Obsolete("No longer used. Remove in 3.0.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

@mjkkirschner I thought we made it clear somewhere that these APIs are not part of Dynamo SDK? If not, let's do that..

Copy link
Member

Choose a reason for hiding this comment

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

@QilongTang we only made that statement in new extension binaries like WorkspaceReferencesExtension - this is a public method in DynamoCoreWPF - we can't remove this method now without some of the other work on reorganizing or componentizing the API we've been discussing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for clarifying. I thought this is in WorkspaceReference project. My bad

@@ -122,6 +123,7 @@ internal PackageHeader GetPackageMaintainers(IPackageInfo packageInfo)
/// <param name="header"></param>
/// <param name="version"></param>
/// <returns></returns>
[Obsolete("No longer used. Remove in 3.0.")]
Copy link
Contributor

@QilongTang QilongTang Apr 6, 2020

Choose a reason for hiding this comment

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

@mmisol I believe Internal APIs can be removed anytime. Unless it is used in a lot of other projects?

public Greg.Responses.PackageHeader Header { get; private set; }
private string _name;
public string Name { get { return Header != null ? Header.name : _name; } set { _name = value; } }

private string _id;
public string Id { get { return Header != null ? Header._id : _id; } set { _id = value; } }
Copy link
Member

@mjkkirschner mjkkirschner Apr 6, 2020

Choose a reason for hiding this comment

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

for public properties please add /// summaries - also, should this really be public? Do we intend for others extension authors / dynamo integrators to use this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is used in DynamoCoreWpf so I'll add comments for it. I don't think someone might want to extend it in some way. This is used as a view model for the installed dependencies when installing a package from the search.

Copy link
Member

@mjkkirschner mjkkirschner Apr 6, 2020

Choose a reason for hiding this comment

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

if it's only to be used by us - maybe we can make it internal and use the internalsVisibleTo attribute, my feeling is that we should be much more deliberate about what constitutes our public api. What do you think?

Copy link
Collaborator Author

@mmisol mmisol Apr 6, 2020

Choose a reason for hiding this comment

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

My opinion is that using InternalsVisibleTo is more of a hack than a good practice. Making something public shouldn't make it "written in stone". I think we should identify exactly what we want our extension points to be instead, and only make promises of backwards compatibility for those.

@mmisol mmisol merged commit 6c994f6 into DynamoDS:master Apr 6, 2020
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.

5 participants