-
Notifications
You must be signed in to change notification settings - Fork 636
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
[Draft] Defer loading of workspace referenced packages until workspace open #11502
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1693,6 +1693,8 @@ private bool OpenJsonFileFromPath(string fileContents, string filePath, bool for | |
OnComputeModelDeserialized(); | ||
|
||
SetPeriodicEvaluation(ws); | ||
|
||
CurrentWorkspace = ws; | ||
} | ||
} | ||
} | ||
|
@@ -1771,7 +1773,7 @@ private void OpenWorkspace(WorkspaceModel ws) | |
} | ||
|
||
AddWorkspace(ws); | ||
CurrentWorkspace = ws; | ||
//CurrentWorkspace = ws; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hope this doesn't cause any side-effects. As noted above I have moved this so that it happens a little later in the workspace opening sequence. |
||
OnWorkspaceOpened(ws); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
using Dynamo.Core; | ||
using Dynamo.Exceptions; | ||
using Dynamo.Extensions; | ||
using Dynamo.Graph.Workspaces; | ||
using Dynamo.Interfaces; | ||
using Dynamo.Logging; | ||
using Dynamo.Utilities; | ||
|
@@ -91,7 +92,7 @@ public PackageLoader(IEnumerable<string> packagesDirectories) | |
if (packagesDirectories == null) | ||
throw new ArgumentNullException("packagesDirectories"); | ||
|
||
this.packagesDirectories.AddRange(packagesDirectories); | ||
//this.packagesDirectories.AddRange(packagesDirectories); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't load all packages, just the ones in the standard lib. |
||
this.packagesDirectories.Add(StandardLibraryDirectory); | ||
|
||
var error = PathHelper.CreateFolderIfNotExist(DefaultPackagesDirectory); | ||
|
@@ -102,6 +103,36 @@ public PackageLoader(IEnumerable<string> packagesDirectories) | |
packagesDirectoriesToVerifyCertificates.Add(StandardLibraryDirectory); | ||
} | ||
|
||
internal void OnWorkspaceOpened(IEnumerable<INodeLibraryDependencyInfo> packageDependencies, | ||
IEnumerable<string> packageDirectories) | ||
{ | ||
var pkgs = new List<Package>(); | ||
foreach (var root in packageDirectories) | ||
{ | ||
foreach (var dir in | ||
Directory.EnumerateDirectories(root, "*", SearchOption.TopDirectoryOnly)) | ||
{ | ||
var headerPath = Path.Combine(dir, "pkg.json"); | ||
if (PathHelper.IsValidPath(headerPath)) | ||
{ | ||
var discoveredPkg = Package.FromJson(headerPath, AsLogger()); | ||
if(discoveredPkg == null) continue; | ||
|
||
foreach (var info in packageDependencies) | ||
{ | ||
// if workspace package dependency is present in downloaded packages, load it. | ||
if (info.Name == discoveredPkg.Name && info.Version.ToString() == discoveredPkg.VersionName) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Collect all downloaded packages that match with the ones referenced in the workspace. |
||
{ | ||
pkgs.Add(discoveredPkg); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
LoadPackages(pkgs); | ||
aparajit-pratap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/// <summary> | ||
/// Initialize a new instance of PackageLoader class | ||
/// </summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,6 +224,12 @@ private void OnCurrentWorkspaceChanged(IWorkspaceModel ws) | |
(ws as WorkspaceModel).CollectingCustomNodePackageDependencies += GetCustomNodePackageFromID; | ||
(ws as WorkspaceModel).CollectingNodePackageDependencies += GetNodePackageFromAssemblyName; | ||
currentWorkspace = ws; | ||
|
||
if (PackageLoader != null && ws is HomeWorkspaceModel model) | ||
{ | ||
PackageLoader.OnWorkspaceOpened(model.NodeLibraryDependencies, | ||
ReadyParams.StartupParams.PathManager.PackagesDirectories); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Called once a new workspace is opened. |
||
} | ||
} | ||
} | ||
|
||
|
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.
Update the current workspace here, after the VM is re-initialized and all libs/packages are reloaded. This will trigger the property changed event for
CurrentWorkspace
at the right time for theDynamoPackages
extension to react to it and load packages for that new workspace.