Skip to content

Conversation

@mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented May 3, 2018

Purpose

@andydandy74 reported missing comments in his converted clockwork package.
This PR serializes type parameter comments into the nodeView of input(symbol) nodes, using as simple as a converter as I could write.

we use the new converter when saving the workspaceViewModel.

At load time, we pull the comment out of the nodeView if the node we're loading is an input node, and then we construct a new type parameter using that comment and existing type paramter, and then set the inputSymbol equal to the string representation of that new type parameter.

This PR serializes the typedParameter.Summary as Description using the existing TypedParamterConverter and adds some tests. It appears that if we load an existing custom node with no Description in the parameter we get an emptyString back from the symbol node - seems reasonable to me.

comments are always appended to the start of the input symbol and they are always wrapped with block comments as the parser throws away everything but the comment's string value. - ie

for //a comment we can only serialize a comment

sample serialization:

 "Parameter": {
        "Name": "inputName",
        "TypeName": "string",
        "TypeRank": 0,
        "DefaultValue": "\"a def string\"",
        "Description": " commentsssss"
      },

TODO:

  • This PR needs tests.

Declarations

Check these if you believe they are true

  • The code base 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

@QilongTang
@ramramps

FYIs

@smangarole @andydandy74

@ramramps
Copy link
Collaborator

ramramps commented May 4, 2018

@mjkkirschner Does summary serializes in NodeView.Parameter? or as Summary in NodeView?

@mjkkirschner
Copy link
Member Author

mjkkirschner commented May 4, 2018

@ramramps Parameter.Summary serializes to NodeView.Summary but we could name it anything.

using Dynamo.Engine;
using Dynamo.Scheduler;
using Newtonsoft.Json.Linq;
using Dynamo.Library;
Copy link
Contributor

Choose a reason for hiding this comment

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

Added this for Nodes.CustomNodes.Symbol type check?

@ramramps
Copy link
Collaborator

ramramps commented May 4, 2018

@mjkkirschner is there a reason for not adding this to Parameter block?
"Parameter": {
"Name": "var1",
"TypeName": "System.DateTime",
"TypeRank": 0,
"DefaultValue": null
},
"

//if the nodeView's model is a symbol node add some extra data.
if ((value as NodeViewModel).NodeModel is Symbol)
{
jobject.Add("Summary", ((value as NodeViewModel).NodeModel as Symbol).Parameter.Summary);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if empty summary will be kept and serialized as empty string? Just curious

@gregmarr
Copy link
Contributor

gregmarr commented May 4, 2018

I asked the same thing, should we add another field to Parameter? I'm fine with that.

@QilongTang
Copy link
Contributor

@gregmarr @ramramps Adding to the param block seems to be cleaner implementation but I thought we agreed compute block only contains stuff meant to be must have for computation?

@gregmarr
Copy link
Contributor

gregmarr commented May 4, 2018

It's better than adding it to the TypeName field as a comment, which is what this looks like it is doing. If we add Parameter.Description it matches Port.Description. I guess the alternative would be adding it under View.NodeModel.

@mjkkirschner
Copy link
Member Author

mjkkirschner commented May 4, 2018

@gregmarr this PR is meant to go into a release quite soon, not just master. Does that cause any issues if we move this to parameter?

Summary already exists on paramter so it's very simple AFAIK to just serialize summary into the parameter...

I'm not sure what you mean here
It's better than adding it to the TypeName field as a comment, which is what this looks like it is doing. We do a funny thing when setting the inputSymbol, the string is parsed back to a new TypedParamter...

@gregmarr
Copy link
Contributor

gregmarr commented May 4, 2018

I'm talking about adding it to the JSON Schema.

@mjkkirschner
Copy link
Member Author

right, so we would get:

"Parameter": {
"Name": "var1",
"TypeName": "System.DateTime",
"TypeRank": 0,
"DefaultValue": null,
"Summary" : "a comment"
},

@ramramps @QilongTang are we okay with that?

@mjkkirschner
Copy link
Member Author

@gregmarr would this change to the schema make it into production?

@gregmarr
Copy link
Contributor

gregmarr commented May 4, 2018

Can we use Description to match Port, Graph, InputData and OutputData?

@QilongTang
Copy link
Contributor

@mjkkirschner I am fine with it given that it is much cleaner, I just thought we do not want to implement it that way in the first place because this looks like a schema change

@mjkkirschner
Copy link
Member Author

Yep, well I was trying to avoid them because I believe they cause work for @gregmarr and we have to reason about what will be in production at what time, but If @gregmarr is fine with it I think its cleaner.

@gregmarr
Copy link
Contributor

gregmarr commented May 4, 2018

We're generally okay with additions to the schema. Since it's adding data that isn't otherwise there, it won't hurt anything. We can have this in CoGS dev immediately, staging and production fairly soon.

@gregmarr
Copy link
Contributor

gregmarr commented May 4, 2018

Well, I'm the one who didn't include it in the schema in the first place, so I'm fine with it. :)

@mjkkirschner
Copy link
Member Author

@ramramps @gregmarr @QilongTang I will change this implementation to serialize like this:

"Parameter": {
"Name": "var1",
"TypeName": "System.DateTime",
"TypeRank": 0,
"DefaultValue": null,
"Description" : "a comment"
},```

@ramramps
Copy link
Collaborator

ramramps commented May 4, 2018

"Description" = "Summary" ?

@mjkkirschner
Copy link
Member Author

yes @gregmarr requested that above to match port.

@ramramps
Copy link
Collaborator

ramramps commented May 4, 2018

Thanks @mjkkirschner just read the comments.. I am fine with Description...

@mjkkirschner mjkkirschner added PTAL Please Take A Look 👀 and removed Requires Changes labels May 4, 2018
@mjkkirschner
Copy link
Member Author

@QilongTang @ramramps made the changes PTAL.

@mjkkirschner
Copy link
Member Author

Any other tests you can think of that I should add here?

writer.WritePropertyName("DefaultValue");
writer.WriteValue(((TypedParameter)value).DefaultValueString);
writer.WritePropertyName("Description");
writer.WriteValue(((TypedParameter)value).Summary);
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@ramramps
Copy link
Collaborator

ramramps commented May 4, 2018

This looks better [ graph serialization / deserilization] . thanks @mjkkirschner
LGTM

@mjkkirschner mjkkirschner changed the title WIP - comments are not serialized with custom node input nodes comments are not serialized with custom node input nodes May 7, 2018
@QilongTang QilongTang added LGTM and removed PTAL Please Take A Look 👀 labels May 7, 2018
@QilongTang QilongTang merged commit 70bcfb2 into DynamoDS:master May 7, 2018
QilongTang pushed a commit that referenced this pull request May 7, 2018
* first commit - seems to be working
needs tests

* get rid of nodeViewModel converter

* add tests
fix comment
@QilongTang QilongTang mentioned this pull request May 7, 2018
7 tasks
QilongTang added a commit that referenced this pull request May 7, 2018
* swtich registration of js object to async verison - we only have access to methods here, and they return promises.

* review comments

* Update library.html

review comments

* comments are not serialized with custom node input nodes (#8825)

* first commit - seems to be working
needs tests

* get rid of nodeViewModel converter

* add tests
fix comment
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.

4 participants