QNTM-3841 Add geometry creation option to Dynamo CLI#8775
QNTM-3841 Add geometry creation option to Dynamo CLI#8775sm6srw merged 32 commits intoDynamoDS:masterfrom
Conversation
| "ProtoGeometry.dll", | ||
| "DesignScriptBuiltin.dll", | ||
| "DSCoreNodes.dll", | ||
| "DSOffice.dll", |
There was a problem hiding this comment.
If we are sure about the performance impact, I see no harm adding these dlls and looks like the comment at line:92 needs to be removed 😉
There was a problem hiding this comment.
this was done initially for optimization workflows that benefited from the slightly faster startup time of ignoring these libraries. It's worth profiling it I think before making this change unless they are simply required for your work @sm6srw.
| "File will have the .json extension and be located in the same directory as the original file.", x => convertFile = x != null) | ||
| .Add("h|H|help", "Get some help", h => showHelp = h != null); | ||
| .Add("h|H|help", "Get some help", h => showHelp = h != null) | ||
| .Add("g=|G=|geometry", "Geometry, Instruct Dynamo to output geometry from all evaluations to a json file at this path", g => geometryFilePath = g); |
There was a problem hiding this comment.
could you update the dynamo CLI wiki page with an example of this format?
There was a problem hiding this comment.
Sure, I will make sure the wiki gets updated.
src/DynamoCLI/CommandLineRunner.cs
Outdated
| /// the results from invoking dynamo from the command line are useable. | ||
| /// </summary> | ||
| public class CommandLineRunner | ||
| public partial class CommandLineRunner |
src/DynamoCLI/CommandLineRunner.cs
Outdated
|
|
||
| if (!String.IsNullOrEmpty(cmdLineArgs.GeometryFilePath)) | ||
| { | ||
| IRenderPackageFactory renderPackageFactory = new DefaultRenderPackageFactory(); |
There was a problem hiding this comment.
should the geometry option take some settings for render package tessellation?
src/DynamoCLI/CommandLineRunner.cs
Outdated
| var jsonFilename = cmdLineArgs.GeometryFilePath; | ||
| using (StreamWriter jsonFile = new StreamWriter(jsonFilename)) | ||
| { | ||
| List<Object> geometry = new List<object>(); |
src/DynamoCLI/CommandLineRunner.cs
Outdated
| if (!String.IsNullOrEmpty(cmdLineArgs.GeometryFilePath)) | ||
| { | ||
| IRenderPackageFactory renderPackageFactory = new DefaultRenderPackageFactory(); | ||
| List<GeometryHolder> nodeGeometries = new List<GeometryHolder>(); |
| matchingNode.IsSetAsInput = updateIsSetAsInput; | ||
| matchingNode.IsSetAsOutput = updateIsSetAsOutput; | ||
| matchingNode.IsFrozen = updateIsFrozen; | ||
| matchingNode.UpdateValue(new UpdateValueParams("IsVisible", updateIsVisible.ToString())); |
There was a problem hiding this comment.
I understand the Frozen aspect of CLI usage but not about IsVisible, can you expand a bit here?
There was a problem hiding this comment.
I think we need to have a discussion around this... I feel this muddies our API separation and while useful could also be solved by CLI creating a viewModel.
src/DynamoCLI/GeometryHolder.cs
Outdated
| } | ||
| } | ||
|
|
||
| groupData.Add("name", nodeModel.GUID.ToString()); |
There was a problem hiding this comment.
hmm, couldn't this dataStructure just be a function that takes a renderPackage and serializes it?
There was a problem hiding this comment.
Is the count > 0 due to custom nodes?
There was a problem hiding this comment.
@saintentropy Not really, it is more about making sure that we are 'Done' and 'HasGeometry' is false if it for whatever reason happens.
| // var output = new XmlDocument(); | ||
| // output.Load(newpath); | ||
| // AssertOutputValuesForGuid("36c30251-c867-4d73-9a3b-24f3e9ab00e5", new List<Tuple<int, string>> { Tuple.Create(0, "{e : 6, d : {4, 5}, a : 1, c : {bar : 999, foo : 99}, b : 2}") }, output); | ||
| // AssertOutputValuesForGuid("6a5bcff0-ce40-4773-aee6-88d99104b4a7", new List<Tuple<int, string>> { Tuple.Create(0, "{a,b,c,d,e}"), Tuple.Create(1, "{1,2,{bar : 999, foo : 99},{4,5},6}") }, output); |
|
@mjkkirschner Thanks, I always forget those. PTAL when you have a moment. |
|
@mjkkirschner Friendly ping! |
| } | ||
| } | ||
| string json = JsonConvert.SerializeObject(geometry); | ||
| jsonFile.Write(json); |
There was a problem hiding this comment.
what if this fails, since it's a CLI utility I guess a crash is not that bad.
There was a problem hiding this comment.
It will be catched and logged in Programs.cs. I think that is good enough for a CLI.
| File.WriteAllText(newFilePath, json); | ||
| } | ||
|
|
||
| public new void Run(StartupUtils.CommandLineArguments args) |
There was a problem hiding this comment.
can you add a summary to this public method.
| <ItemGroup> | ||
| <Reference Include="Microsoft.Practices.Prism, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> | ||
| <Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
| <HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> |
There was a problem hiding this comment.
does this version of newtonsoft.JSON match the rest of the repo - I think we might be on 8.02 - @alfarok did you plan to update core to 8.03?
There was a problem hiding this comment.
As far as I can tell, all projects are already on 8.03.
There was a problem hiding this comment.
@mjkkirschner I think @sm6srw is correct, I see 8.03 in Core. We were discussing updating NUnit to a newer version but I don't think there were plans to update json.net
src/DynamoWPFCLI/GeometryHolder.cs
Outdated
| } | ||
| } | ||
|
|
||
| public void Dispose() |
| { | ||
| node = nodeModel; | ||
| nodeModel.RenderPackagesUpdated += NodeRenderPackagesUpdated; | ||
| if (!nodeModel.RequestVisualUpdateAsync(model.Scheduler, model.EngineController, factory, true)) |
There was a problem hiding this comment.
what does this do? Can you add a comment?
| node.RenderPackagesUpdated -= NodeRenderPackagesUpdated; | ||
| } | ||
|
|
||
| private void NodeRenderPackagesUpdated(NodeModel nodeModel, RenderPackageCache renderPackages) |
There was a problem hiding this comment.
I guess I'm a little confused why this function can't just be a method that takes a list of renderPackages and serializes them. Is it to use JSON.net directly to make serialization more automatic?
There was a problem hiding this comment.
Well, this will change in the next sprint or two when we make our final decision of what format to use. The answer could be a direct serialization of the renderPackages or something else. I leave it "as is" for now because it happens to work with the testing tools I have.
| try | ||
| { | ||
| DynamoModel.IsCrashing = true; | ||
| Dynamo.Logging.Analytics.TrackException(e, true); |
There was a problem hiding this comment.
hmm, do we want to log crashes for the CLI?
There was a problem hiding this comment.
We already do it in the other CLI. I just follow the same pattern. Do we want to change it?
| @@ -0,0 +1,4 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <packages> | |||
| <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" /> | |||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Reference Include="Microsoft.Practices.Prism, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> | ||
| <Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
| @@ -0,0 +1,4 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <packages> | |||
| <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" /> | |||
|
@sm6srw looks good to me, a few last questions though. |
|
@mjkkirschner Please take a quick final look. Many thanks! |
|
@sm6srw looks good to me. |
|
@mjkkirschner I see no reason, master is already 2.1.0 from now on. Safe to merge |
|
Thanks a lot! |
* POC * Cleanup code. * Add command line option -g for generating geometry json file. * Remove filtering * Fix node state flags at load time. * Use UpdateValue for setting isVisible on node model. Revert set to private. * Remove filtering. * Clean up holder code. * Cleanup converter code. Use node model defaults as starting point. * Preload the same libraries for CLI as for Sandbox. * Add color support * Simplify json * Update file format. * Remove property expressions. * Restore comment. * Restore Cef Settings * Add unit test for CLI geometry option. * Remove comment. * Don't extend CommandLineRunner. * Use var when possible. * Remove commented out code. * Use DynamoViewModel in CLI. * Use DefaultWatch3DViewModel for CLI. * Add new project DynamoWPFCLI. * Let CommandLineRunnerWPF inherit from CommandLineRunner. * Fix review comments. * Fix unstable unit tests. * Remove Dispose method. * Add comments
* Add RegisterFroTrace attribute as a trigger in Json serialization of trace * PR comment * [ 2.0 Release Cut ] Bump Up Master Patch Version (#8647) * Bump Up Patch Version * Add version * Update comments and version baseline * Address Comments * CubicMillimeterToCubicMeter conversion * Revert "CubicMillimeter To CubicMeter conversion" * Fix the units bug * Remove thread sleep * missed the test * Fix static property compilation and crash (#8649) * fix crash, compilation of static property * code cleanup * add test * add test graph * QNTM-3646: Fix creation of unwanted input port for list index-assignment (#8648) * fix for additional input port * fixes for output ports * update tests * added test, code cleanup * address review comments * QNTM-3279: Fix for crash when trying to directly call properties on class name (#8661) * fix for compiling property method as function pointer * code cleanup * add tests * Cherry-pick #8663 (#8664) * Update failing tests (#8663) * update tests * Merge LibG binaries with Geometry.Approximate API (#8666) * merge LibG binaries with Geometry.Approximate() * Update license * scroll bar fix in incanvas search * QNTM-3641: Prevent ColorRange node from crashing with old style List syntax (#8670) (#8674) * fix crash with ColorRange1D node * add test * add test set unsaved changes false when initializing json custom node * Update changes from librarie.js to fix QNTM-3710 (#8678) After investigating the errors in the EngOps check it was thought that these changes could not have caused the current failures. Other PRs have also shown the same issues. Given all of that, this PR is being merged. * address comments * Update LibG binaries for ASM224 branch (#8681) * update LibG binaries for ASM224 branch * PR comment * QNTM-3841 Add geometry creation option to Dynamo CLI (#8775) * POC * Cleanup code. * Add command line option -g for generating geometry json file. * Remove filtering * Fix node state flags at load time. * Use UpdateValue for setting isVisible on node model. Revert set to private. * Remove filtering. * Clean up holder code. * Cleanup converter code. Use node model defaults as starting point. * Preload the same libraries for CLI as for Sandbox. * Add color support * Simplify json * Update file format. * Remove property expressions. * Restore comment. * Restore Cef Settings * Add unit test for CLI geometry option. * Remove comment. * Don't extend CommandLineRunner. * Use var when possible. * Remove commented out code. * Use DynamoViewModel in CLI. * Use DefaultWatch3DViewModel for CLI. * Add new project DynamoWPFCLI. * Let CommandLineRunnerWPF inherit from CommandLineRunner. * Fix review comments. * Fix unstable unit tests. * Remove Dispose method. * Add comments * Fix type check * Apply same fix to NodeInputData * Add serialization tests * Fix typo in Extansion. * QNTM-4278 DynamoWPFCLI should use CoGs geometry format (#8887) * POC * Cleanup code. * Add command line option -g for generating geometry json file. * Remove filtering * Fix node state flags at load time. * Use UpdateValue for setting isVisible on node model. Revert set to private. * Remove filtering. * Clean up holder code. * Cleanup converter code. Use node model defaults as starting point. * Preload the same libraries for CLI as for Sandbox. * Add color support * Simplify json * Update file format. * Remove property expressions. * Restore comment. * Restore Cef Settings * Add unit test for CLI geometry option. * Remove comment. * Don't extend CommandLineRunner. * Use var when possible. * Remove commented out code. * Use DynamoViewModel in CLI. * Use DefaultWatch3DViewModel for CLI. * Add new project DynamoWPFCLI. * Let CommandLineRunnerWPF inherit from CommandLineRunner. * Fix review comments. * Fix unstable unit tests. * Remove Dispose method. * Add comments * First pass * Formatting fixes. * Remove XML stuff. * Some final adjustments. * Add more comments. * Move comment. * Only store the geometry array. * Refactor. * Add interface * Make interface internal * Rename implmentation. * Allow internal access for CLI * Move default implementation to core. * Make setters private * Address review comments. * match Revit CEF intitializtion settings * match Revit CEF intitializtion settings * match Revit CEF intitializtion settings * QNTM-5580 - Correct Typo in the Dynamo json serialization to match CoGS API (#9170) * Fix typo * Obsolete the existing property * Update test * remove expression body syntax * Add serialization test with typo * AVP NumberInputNode deserialization * add testing * QNTM-5568 Refinery needs to support culture invariance for number fmt, part Deux (#9178) * Don't culture format value strings. * Assume value strings are formated with `InvariantCulture` * Add tests * More work on tests * Clarify switching of cultures
Purpose
This PR:
Declarations
Check these if you believe they are true
N/A User facing strings, if any, are extracted into
*.resxfilesN/A Snapshot of UI changes, if any.
N/A Changes to the API follow Semantic Versioning, and are documented in the API Changes document.
Reviewers
@mjkkirschner @QilongTang
FYIs
@saintentropy @Racel