Skip to content

unify import libs in CLI/WPFCLI#16138

Closed
pinzart90 wants to merge 2 commits intomasterfrom
import_paths
Closed

unify import libs in CLI/WPFCLI#16138
pinzart90 wants to merge 2 commits intomasterfrom
import_paths

Conversation

@pinzart90
Copy link
Copy Markdown
Contributor

@pinzart90 pinzart90 commented Apr 10, 2025

Purpose

Add import libs to the MakeCLIModel(CommandLineArguments cmdLineArgs) API

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

(FILL ME IN) Brief description of the fix / enhancement. Use N/A to indicate that the changes in this pull request do not apply to Release Notes. Mandatory section

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

Comment thread src/DynamoApplications/StartupUtils.cs Outdated
ImportAssembly(model, path);
});
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this makes it a lot easier (and less code) to use Dynamo for Design automation

Copy link
Copy Markdown
Contributor

@aparajit-pratap aparajit-pratap Apr 10, 2025

Choose a reason for hiding this comment

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

If you're importing these assemblies over here, shouldn't you skip importing them again over here and here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ugh, you're right. I will refactor

Comment thread src/DynamoApplications/StartupUtils.cs Outdated
commonDataFolder: cmdLineArgs.CommonDataFolder,
serviceMode: cmdLineArgs.ServiceMode);
serviceMode: cmdLineArgs.ServiceMode,
importedPaths: cmdLineArgs.ImportedPaths);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm confused why this is necessary?
the CLI already sets imported paths from cli args, doesn't it?

https://github.com/DynamoDS/Dynamo/blob/master/src/DynamoApplications/StartupUtils.cs#L100

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed this

Comment thread src/DynamoApplications/StartupUtils.cs Outdated
/// </summary>
/// <param name="model"></param>
/// <param name="path"></param>
internal static void ImportAssembly(DynamoModel model, string path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

any thoughts on how to unify these duplicate functions now?

https://github.com/DynamoDS/Dynamo/blob/master/src/DynamoCLI/CommandLineRunner.cs#L96

I don't know why the DynamoCoreWPFCLI did not use the protected method, does it not inherit from the base class?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I refactored the methods to use a single import function.

@mjkkirschner
Copy link
Copy Markdown
Member

mjkkirschner commented Apr 10, 2025

@pinzart90 for posterity can you either change the description or title of this PR to be more clear that you want this functionality for the DynamoModel in general? To me anyway it was confusing at first glance because this functionality already exists for the CLIs.

@pinzart90 pinzart90 changed the title implement load libs from import paths unify import libs in CLI/WPFCLI Apr 10, 2025
@pinzart90
Copy link
Copy Markdown
Contributor Author

the DynamoModel in general

Sorry about the confusion. I want the import functionality to be available for the public static DynamoModel MakeCLIModel(CommandLineArguments cmdLineArgs) function.

commonDataFolder: cmdLineArgs.CommonDataFolder,
serviceMode: cmdLineArgs.ServiceMode);

ImportAssemblies(model, cmdLineArgs.ImportedPaths);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there an extra import step happening here that wasn't happening before?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This definitely sticks out as a strange place for this code to live. I would just expect this method to create a dynamo model?

Copy link
Copy Markdown
Member

@mjkkirschner mjkkirschner Apr 11, 2025

Choose a reason for hiding this comment

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

It seems like you are trying to get around your implementation in that you're creating a CLI model in design automation but you're not really using a CLI entry point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, why should it matter if the model is used by DynamoCLI or another CLI (in my case the DesignAutomationCLI).
My indention is to have a simple, clean way to build a model for the purposes of being used in a headless way

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The cmdLineArgs input (for MakeCLIModel) allows specifying ImportedPaths, but it is not used.
There is no public API to import libs (that I could find). I could call the import API outside of the MakeModel call/..with no need for this PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this clean?

This function doesn't do what it says on the tin anymore.
Won't this also cause the dynamo CLIs to attempt to import these assemblies twice- I guess that's probably, ok - though it could be slow?

why can't DesignAutomationCLI use the same set of flags the other CLI's do and just import assemblies that way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry, I did not notice the double import call

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

evidently not simple or clear enough
I can simply try to expose the Import function...or the existing StartupDynamo method, and revert everythign else

Copy link
Copy Markdown
Contributor Author

@pinzart90 pinzart90 Apr 11, 2025

Choose a reason for hiding this comment

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

Part of the confusion is that the method MakeCLIModel has arguments that take no effect when you make the function call. Maybe it should be made clear that the importPaths are not meant for that function ...

@pinzart90 pinzart90 closed this Apr 11, 2025
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.

3 participants