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

DYN-5709: Pm publish version patch request #15395

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dnenov
Copy link
Collaborator

@dnenov dnenov commented Jul 18, 2024

Purpose

An urgent request to 'fix' the Publish version experience.

  • historically, when publishing a new package or a new package version, we would re-build the package anew every time. This creates a number of issues around tempering with loaded resources (removing, overriding, loading, unloading)
  • we make an assumption that if a package is installed, the user wants to publish (either as a brand new package, or a version) the actual installed package with its existing files and folder structure
  • this means that we disable the option to add/remove files when publishing from locally installed package
  • which allows us to simply zip the existing files and folders package structure, only amending the Header file as needed

For review. Needs testing.

User experience

Installed Packages
image

Edit package details (header); Publish Locally is disabled
image

'Edit' is still available to preview the package structure, but editing options are disabled
image

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
  • This PR contains no files larger than 50 MB

Release Notes

  • now Publish installed package also uses RetainFolderStructure
  • both Publish and Publish version now mark the package as installed
  • if a package is installed (IsPackageInstalled) then we bypass the standard build procedure, and use (zip) the existing package folder
  • if a package is installed the editing functionalities of the publish package workflow are disabled, ie. we cannot add/remove files (as this will require a rebuild)
  • if a package is installed we don't allow local installation, only publish online (as the package is already installed after all?)
  • also allows local package to be published only after it has been created (merged DYN-5709 jira request, as it overlaps a bit)

Reviewers

@aparajit-pratap
@mjkkirschner

FYIs

@QilongTang
@zeusongit
@reddyashish

- changed publish package command restrictions
- located the place where dll files would cause error on deletion
- dll being loaded doesn't seem to be a problem
- historically, when publishing a new package or a new package version, we would re-build the package anew every time. This creates a number of issues around tempering with loaded resources (removing, overriding, loading, unloading)
- we make an assumption, that if a package is installed, the user wants to publish (either as a brand new package, or a version) the actual installed package with its existing files and folder structure
- this means that we disable the option to dynamically add/remove files if we publish from locally installed package
- which allows us to simply zip the existing folder structure, only amending the Header file as needed
@github-actions github-actions bot changed the title Pm publish version patch request DYN-5709: Pm publish version patch request Jul 18, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-5709

Copy link

github-actions bot commented Jul 18, 2024

UI Smoke Tests

Test: success. 11 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests - net8.0

@QilongTang QilongTang added this to the 3.3 milestone Jul 18, 2024
@aparajit-pratap
Copy link
Contributor

aparajit-pratap commented Jul 18, 2024

if a package is installed we don't allow local installation, only publish online (as the package is already installed after all?)

@dnenov instead of disabling publish locally can we still keep it enabled and instead disable reloading the package after it has been published? This helps a lot with testing whether your package will eventually be published online correctly.

// If the current user is the package holder and a package with that name has not been published yet, return true
private bool PackageNotPublishedAndUserIsHolder(Package package, string username)
{
bool userIsHolder = package.CopyrightHolder != null && package.CopyrightHolder.Equals(username);
Copy link
Contributor

@aparajit-pratap aparajit-pratap Jul 18, 2024

Choose a reason for hiding this comment

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

Is the copyright information coming from the pkg.json file? What if it's missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

How about renaming this function as IsPackageUnpublishedAndUserHolder?

{
if (!CanPublish) return false;

return packageManagerClient.DoesCurrentUserOwnPackage(Model, dynamoModel.AuthenticationManager.Username) ||
Copy link
Contributor

@aparajit-pratap aparajit-pratap Jul 18, 2024

Choose a reason for hiding this comment

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

Does the DoesCurrentUserOwnPackage check mean that the package cannot be republished by someone who hasn't published it before?

Copy link
Contributor

@aparajit-pratap aparajit-pratap Jul 18, 2024

Choose a reason for hiding this comment

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

It looks like only an existing package maintainer or package copyright holder can republish (publish a new version) the package? The code would be clearer if you said something like:

bool isUserOwnerOrHolder = packageManagerClient.DoesCurrentUserOwnPackage(Model, dynamoModel.AuthenticationManager.Username) || PackageNotPublishedAndUserIsHolder(Model, dynamoModel.AuthenticationManager.Username);
return isUserOwnerOrHolder;

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait..Copyright Holder should not be able to publish a version or a package, we do not validate copyright holder on server side, any actions related to package publishing either republishing from local copy or publishing a version should be limited to its current maintainers only.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Understood.

vm.IsNewVersion = false;
vm.IsPackageInstalled = true;
Copy link
Contributor

@aparajit-pratap aparajit-pratap Jul 18, 2024

Choose a reason for hiding this comment

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

Will this always be true? In the case of publishing a new package, the new package doesn't need to always be loaded, does it?

@@ -2117,9 +2136,9 @@ private void RemoveSingleItem(PackageItemRootViewModel vm, DependencyType fileTy
}
}

private bool CanShowAddFileDialogAndAdd()
private bool CanAddFiles()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just remove this redundant property (it's just the inverse of IsPackageInstalled) and use IsPackageInstalled directly?

@zeusongit
Copy link
Contributor

zeusongit commented Jul 18, 2024

this means that we disable the option to add/remove files when publishing from locally installed package

what is the process to include new version of the existing dll in your package, or removing existing ones?

@aparajit-pratap
Copy link
Contributor

@dnenov I was able to publish the DynamoForma package with these changes 🎉 Thank you!

A couple of comments:

To @zeusongit's point, I now understand why the publish version workflow was designed the way it is today:
I was unable to mark files as node libraries in the edit UI. This would need more discussion/design as it could mean that the new package isn't loaded properly in Dynamo in the first place without the node libraries updated.

One workaround for this could be that we require authors to manually edit the pkg.json file with the newly updated node libraries if they want to publish the package while being loaded correctly. We then completely disable editing node library checks in the UI, we simply display them as read-only. This, however, is not an intuitive option and difficult to message/make discoverable to package authors.

On second thoughts I think it's best to revert to the old publish version workflow of allowing adding/removing files (including node library tagging), then publishing the edited package but not reloading it in the same Dynamo session. We could simply message that users would need to restart Dynamo to load the edited package.

Thoughts @zeusongit?

@aparajit-pratap
Copy link
Contributor

aparajit-pratap commented Jul 18, 2024

this means that we disable the option to add/remove files when publishing from locally installed package

what is the process to include new version of the existing dll in your package, or removing existing ones?

@zeusongit when @dnenov and I discussed this, we found that it makes it very complicated to add or remove files to an already loaded package and then republish it as a new version/package (I think because the new package post-edits is then loaded in the same Dynamo session). We therefore decided to simplify this workflow by disallowing file addition or removal while publishing an already installed package. If this is required, the idea is for the package author to have the package in its final, ready-to-publish state already loaded in Dynamo before publishing it.

However, this new approach has its disadvantages as well. Please see my comment above.

@dnenov
Copy link
Collaborator Author

dnenov commented Jul 19, 2024

Hi @aparajit-pratap @QilongTang. Thank you for your comments. I was hoping that this line of simplification might be a good one, but it might turn out that it's not.

Here are some of my thoughts:

  • On the technical side, I am mostly concerned with manipulations around loaded assemblies. Basically, the moment a package is loaded, we really don't want to publish it anymore. Which opens a few questions - when is a package being loaded. I actually don't know the answer to that question, and need to check. If a package is loaded the moment Dynamo starts .. then how are we ever going to publish an installed package? (I use 'publish' to mean 'submit online' here).

Actually, would it be OK if we had a call around a few more questions?

@zeusongit
Copy link
Contributor

zeusongit commented Jul 19, 2024

@dnenov I was able to publish the DynamoForma package with these changes 🎉 Thank you!

A couple of comments:

To @zeusongit's point, I now understand why the publish version workflow was designed the way it is today: I was unable to mark files as node libraries in the edit UI. This would need more discussion/design as it could mean that the new package isn't loaded properly in Dynamo in the first place without the node libraries updated.

One workaround for this could be that we require authors to manually edit the pkg.json file with the newly updated node libraries if they want to publish the package while being loaded correctly. We then completely disable editing node library checks in the UI, we simply display them as read-only. This, however, is not an intuitive option and difficult to message/make discoverable to package authors.

On second thoughts I think it's best to revert to the old publish version workflow of allowing adding/removing files (including node library tagging), then publishing the edited package but not reloading it in the same Dynamo session. We could simply message that users would need to restart Dynamo to load the edited package.

Thoughts @zeusongit?

Agreed, second option makes sense. But I can think of some ways that may be a problem, like adding binaries which are unchanged and already exist.

@dnenov
Copy link
Collaborator Author

dnenov commented Jul 22, 2024

Parking this one after discussion with @zeusongit and @QilongTang. Will pursue a proper context isolation per plugin as a way to move forward.

@dnenov dnenov closed this Jul 22, 2024
@aparajit-pratap
Copy link
Contributor

I can think of some ways that may be a problem, like adding binaries which are unchanged and already exist.

@zeusongit why would that be a problem?

@dnenov
Copy link
Collaborator Author

dnenov commented Jul 24, 2024

Opening up as a temp solution to the currently broken Publish version workflow.

@dnenov dnenov reopened this Jul 24, 2024
@dnenov dnenov marked this pull request as draft July 24, 2024 15:08
@QilongTang
Copy link
Contributor

@dnenov This PR is no longer required right?

@QilongTang QilongTang removed this from the 3.3 milestone Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants