Skip to content

Serialize sessionTraceData to Bindings - #7941

Merged
QilongTang merged 18 commits into
masterfrom
Serialize-sessionTraceData
Jun 13, 2017
Merged

QilongTang merged 18 commits into
masterfrom
Serialize-sessionTraceData

Conversation

@QilongTang

@QilongTang QilongTang commented Jun 8, 2017 •

Copy link
Copy Markdown
Contributor

Purpose

QNTM-701
In Dynamo Core, Graph.JSON should have "Bindings" instead of "sessionTraceData"

This PR:

  1. Deletes the existing sessionTraceData xml serialization logic
  2. Append bindings serialization logic to workspace serialization

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

@mjkkirschner @ramramps @gregmarr

FYIs

@ikeough

@QilongTang QilongTang added the WIP label Jun 8, 2017
internal static readonly string SessionTraceDataXmlTag = "SessionTraceData";
internal static readonly string NodeTraceDataXmlTag = "NodeTraceData";
internal static readonly string CallsiteTraceDataXmlTag = "CallsiteTraceData";
internal static readonly string SessionTraceDataTag = "Bindings";

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.

will changing this string break xml deserialization of session data?

@QilongTang QilongTang Jun 8, 2017 •

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.

Good point. I think unfortunately, yes. LoadTraceDataFromXmlDocument will still be used for legacy dyn opening as part of DynamoCore 2.0 and it will be checking the old xml tag from the old dyns. I will revert the related changes. For the new json block bindings, I can hardcode the json block name just like the other ones. But should we also consider making a config file to store all these json property names? @ikeough

@mjkkirschner mjkkirschner Jun 8, 2017 •

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.

why don't you just add an additional const and then use the json one in the json serialization and the xml one in xml deserialization...
I'm also curious did you try adding a serializer specifically for the callSiteTrace data class - or attaching a converter that class directly to json.

My preference would be to avoid adding more and more logic to this workspace converter.

@QilongTang

QilongTang commented Jun 12, 2017 •

Copy link
Copy Markdown
Contributor Author

With the changes in the PR, the serialized data currently looks like this.

"Bindings": [
    {
      "NodeTraceData NodeId": "a36a5bdc-8c94-41e0-9247-e5cc9a9a3de7",
      "CallsiteTraceData": [
        {
          "CallSiteID ByCurve_InClassDecl-1_InFunctionScope-1_Instance0_a36a5bdc-8c94-41e0-9247-e5cc9a9a3de7": "PFNPQVAtRU5WOkVudmVsb3BlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOlNPQVAtRU5DPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VuY29kaW5nLyIgeG1sbnM6U09BUC1FTlY9Imh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3NvYXAvZW52ZWxvcGUvIiB4bWxuczpjbHI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vc29hcC9lbmNvZGluZy9jbHIvMS4wIiBTT0FQLUVOVjplbmNvZGluZ1N0eWxlPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VuY29kaW5nLyI+DQo8U09BUC1FTlY6Qm9keT4NCjxhMTpDYWxsU2l0ZV94MDAyQl9UcmFjZVNlcmlhbGlzZXJIZWxwZXIgaWQ9InJlZi0xIiB4bWxuczphMT0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9jbHIvbnNhc3NlbS9Qcm90b0NvcmUvUHJvdG9Db3JlJTJDJTIwVmVyc2lvbiUzRDIuMC4wLjUyODUlMkMlMjBDdWx0dXJlJTNEbmV1dHJhbCUyQyUyMFB1YmxpY0tleVRva2VuJTNEbnVsbCI+DQo8TnVtY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xNMFF5TGpBdU1DNDFNalUxSlRKREpUSXdRM1ZzZEhWeVpTVXpSRzVsZFhSeVlXd2xNa01sTWpCUWRXSnNhV05MWlhsVWIydGxiaVV6Ukc1MWJHd2lQZzBLUEhOMGNtbHVaMGxFSUdsa1BTSnlaV1l0TXlJK09HTmtNREJsTlRRdFpEUXpNeTAwWlRWaExUazJPV1V0WmpKa1pqQTJNbU0yWVdKaExUQXdNVEE1TkRneVBDOXpkSEpwYm1kSlJENE5DanhwYm5SSlJENHhNRGcyTlRrMFBDOXBiblJKUkQ0TkNqd3ZZVEU2VTJWeWFXRnNhWHBoWW14bFNXUStEUW84TDFOUFFWQXRSVTVXT2tKdlpIaytEUW84TDFOUFFWQXRSVTVXT2tWdWRtVnNiM0JsUGcwSzwvQmFzZS0wX0RhdGE+DQo8QmFzZS0wX0hhc05lc3RlZERhdGE+ZmFsc2U8L0Jhc2UtMF9IYXNOZXN0ZWREYXRhPg0KPC9hMTpDYWxsU2l0ZV94MDAyQl9UcmFjZVNlcmlhbGlzZXJIZWxwZXI+DQo8L1NPQVAtRU5WOkJvZHk+DQo8L1NPQVAtRU5WOkVudmVsb3BlPg0K"
        }
      ]
    }
  ]

I suspect we can simplify the format even further like the following but would like to gather some thoughts around this @ramramps @mjkkirschner @sharadkjaiswal :

"Bindings": [
    {
      "NodeId": "a36a5bdc-8c94-41e0-9247-e5cc9a9a3de7",
      "CallsiteTraceData": [
        {
          "ByCurve_InClassDecl-1_InFunctionScope-1_Instance0_a36a5bdc-8c94-41e0-9247-e5cc9a9a3de7": "PFNPQVAtRU5WOkVudmVsb3BlIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOlNPQVAtRU5DPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VuY29kaW5nLyI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PC9hMTpDYWxsU2l0ZV94MDAyQl9UcmFjZVNlcmlhbGlzZXJIZWxwZXI+DQo8L1NPQVAtRU5WOkJvZHk+DQo8L1NPQVAtRU5WOkVudmVsb3BlPg0K"
        }
      ]
    }
  ]

@mjkkirschner

Copy link
Copy Markdown
Member

@QilongTang both of those look a little funny.
Have you tried replicating a node and seeing what the output looks like?

If you remove these property names, will it be difficult these deserialize this objects?

As ugly as it is, it seems this should be a series of nested objects.

@gregmarr

Copy link
Copy Markdown
Contributor

This is very similar to what I was just proposing to Ian on Slack.

Quote:

Bindings:
  type: array
  items:
    type: object
    required:
    - node_id
    - binding
    properties:
      node_id:
        format: string
      binding:
        format: string

or something like this:

      Bindings:
        additionalProperties:
          type: array
          items:
            type: string

Looks like this latter one does not seem to show up properly in swagger-ui until 3.0 though.
The latter is a plain bucket of random name-string pairs.

Bindings: [ "foo": "bar", "baz": "blargh"]

The former is more structured:

Bindings: [ { "node_id": "foo", "binding": "bar" }, { "node_id": "baz", "binding": "blargh" } ]

and allows for future expansion if we need to add a second value for some reason.

We could theoretically combine the two, and have "binding" be the place for the additionalProperties, so it's one node id, and then a map of key-value pairs, so you could have a "D4Revit" binding, and a "D4Rhino" binding.

End Quote

Looks like we already need the last one.

    Bindings:
      type: array
      items:
        $ref: "#/definitions/Binding"

Binding:
  type: object
  required:
  - NodeId
  properties:
    NodeId:
      format: string
  additionalProperties:
    type: array
    items:
      type: string

@gregmarr

gregmarr commented Jun 12, 2017 •

Copy link
Copy Markdown
Contributor

I used "string" as the value type in additionalProperties because #7747 says that the values are base64 encoded strings. Do we need to change that?
Actually, as written above it's an array of strings, it should probably actually just be this based on #7747

  additionalProperties:
   type: string

@mjkkirschner

Copy link
Copy Markdown
Member

@gregmarr I might be mistaken, but per node ID I think there can be multiple callsite bindings (atleast in DynamoRevit) @QilongTang can you confirm or deny that?, so I guess we're missing an array of bindings per node, unless the binding object can be whatever type is required. - more like the additional properties one.

@QilongTang

QilongTang commented Jun 12, 2017 •

Copy link
Copy Markdown
Contributor Author

@mjkkirschner Yes, per node Id there can be multiple callSite bindings. That's why I put CallsiteTraceData as an array of object in the first pass. @gregmarr string seems fine

@QilongTang

QilongTang commented Jun 13, 2017 •

Copy link
Copy Markdown
Contributor Author

@mjkkirschner @gregmarr Updated the format to remove the property names and add binding, it looks like this right now as a combination of the two in your quote. What do you think? @sharadkjaiswal @Randy-Ma Is the id for callSiteRawData unique so I can store it this way?

"Bindings": [
    {
      "NodeId": "a36a5bdc-8c94-41e0-9247-e5cc9a9a3de7",
      "Binding": [
        {
          "callSiteTraceDataId1": "callSiteTraceData1",
          "callSiteTraceDataId2": "callSiteTraceData2",
        },
       { Rihno binding },
       { Other binding}
      ]
    },
    {
      "NodeId": "1825d7c7-a85c-4065-bafb-2b97c38a9feb",
      "Binding": [
        {
          "callSiteTraceDataId1": "callSiteTraceData1",
          "callSiteTraceDataId2": "callSiteTraceData2",
        },
       { Rihno binding },
       { Other binding}
      ]
    }
  ]

@gregmarr

Copy link
Copy Markdown
Contributor

That looks good to me.

@QilongTang

Copy link
Copy Markdown
Contributor Author

@gregmarr Do you imagine we serialize client Name in each Binding block as well? I assume in this way the deserialization would be challenging that client need to figure out which block of binding belongs to itself

@gregmarr

gregmarr commented Jun 13, 2017 •

Copy link
Copy Markdown
Contributor

I just noticed that there is different nesting there than I thought before. This is what I would expect with a schema of

Binding:
  type: object
  required:
  - NodeId
  properties:
    NodeId:
      format: string
  additionalProperties:
    type: array
    items:
      type: string
"Bindings": [
    {
      "NodeId": "a36a5bdc-8c94-41e0-9247-e5cc9a9a3de7",
      "Binding":
        {
          "callSiteTraceDataId1": ["callSiteTraceData1"],
          "callSiteTraceDataId2": ["callSiteTraceData2"],
          "Rhino binding": ["foo", "bar"],
          "Other binding": []
        }
    },
    {
...
    }
  ]

If we don't need the array there, and it's one key to one value, then it's just

Binding:
  type: object
  required:
  - NodeId
  properties:
    NodeId:
      format: string
  additionalProperties:
    type: string

and

"Bindings": [
    {
      "NodeId": "a36a5bdc-8c94-41e0-9247-e5cc9a9a3de7",
      "Binding":
        {
          "callSiteTraceDataId1": "callSiteTraceData1",
          "callSiteTraceDataId2": "callSiteTraceData2",
          "Rhino binding": "foo",
          "Other binding": "bar"
        }
    },
    {
...
    }
  ]

@QilongTang

Copy link
Copy Markdown
Contributor Author

@gregmarr Removed the extra array layer, I think it is not necessary right now, so it aligns with your expectation:

"Bindings": [
    {
      "NodeId": "a36a5bdc-8c94-41e0-9247-e5cc9a9a3de7",
      "Binding":
        {
          "callSiteTraceDataId1": "callSiteTraceData1",
          "callSiteTraceDataId2": "callSiteTraceData2",
          "Rhino binding": "foo",
          "Other binding": "bar"
        }
    },
    {
...
    }
  ]

@QilongTang QilongTang changed the title [WIP] Serialize sessionTraceData to Bindings Serialize sessionTraceData to Bindings Jun 13, 2017
@QilongTang QilongTang removed the WIP label Jun 13, 2017
@gregmarr

Copy link
Copy Markdown
Contributor

Perfect, thanks.

@QilongTang

Copy link
Copy Markdown
Contributor Author

A follow up task https://jira.autodesk.com/browse/QNTM-870 created as part of enabling opening such JSON format in D4R. Merging.

@QilongTang
QilongTang merged commit ae3a6f5 into master Jun 13, 2017
@QilongTang
QilongTang deleted the Serialize-sessionTraceData branch June 13, 2017 14:55
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