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

export as JSON process graph #50

Merged
merged 5 commits into from
Jul 17, 2021
Merged

export as JSON process graph #50

merged 5 commits into from
Jul 17, 2021

Conversation

jonathom
Copy link
Member

@m-mohr can you add the js part or point me in the right direction? toJSON seemed to only export the current process node.

@m-mohr
Copy link
Member

m-mohr commented Jul 15, 2021

Have you tried JSON.stringifly(builder.toJSON(), null, 2)?

@jonathom
Copy link
Member Author

Ah, thanks! But pasting the graph into the web editor and clicking "visual model", I get No result node found for process graph. That seems to be because the property "result": true is not set in "process_id": "save_result", when doing

    let graph = JSON.stringify(builder.toJSON(), null, 2)
    console.log(graph)

Example graph from JSON.stringify without "result": true:

{
  "process_graph": {
    "loadco1": {
      "process_id": "load_collection",
      "arguments": {
        "id": "SENTINEL2_L2A_SENTINELHUB",
        "spatial_extent": {
          "west": 8.5464,
          "south": 54.4473,
          "east": 9.0724,
          "north": 54.5685
        },
        "temporal_extent": [
          "2021-03-05",
          "2021-03-05"
        ],
        "bands": [
          "B02",
          "B04",
          "B08",
          "SCL"
        ]
      }
    },
    "reduce1": {
      "process_id": "reduce_dimension",
      "arguments": {
        "data": {
          "from_node": "loadco1"
        },
        "reducer": {
          "process_graph": {
            "arraye1": {
              "process_id": "array_element",
              "arguments": {
                "data": {
                  "from_parameter": "data"
                },
                "index": 2
              }
            },
            "arraye2": {
              "process_id": "array_element",
              "arguments": {
                "data": {
                  "from_parameter": "data"
                },
                "index": 1
              }
            },
            "normal1": {
              "process_id": "normalized_difference",
              "arguments": {
                "x": {
                  "from_node": "arraye1"
                },
                "y": {
                  "from_node": "arraye2"
                }
              },
              "result": true
            }
          }
        },
        "dimension": "bands"
      }
    },
    "savere1": {
      "process_id": "save_result",
      "arguments": {
        "data": {
          "from_node": "reduce1"
        },
        "format": "GTiff"
      }
    }
  }
}

@m-mohr
Copy link
Member

m-mohr commented Jul 15, 2021

Yes, on the last node you need to set node.result = true. The client does that automatically for the normal use-cases, but JSON export is not meant to be a best-practice so it's not optimized for that.

@jonathom
Copy link
Member Author

Ok as it is @m-mohr?

@m-mohr
Copy link
Member

m-mohr commented Jul 15, 2021

I'll do a review on Monday at the latest, I think some wording should be improved. But don't have the time right now...

<template v-slot:r>

```r
graph <- as(res, "Graph")
Copy link
Member

Choose a reason for hiding this comment

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

The proposed solution here looks different: Open-EO/openeo-r-client#54
Not sure though what works better.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! "as Graph" is indeed wrong here. Changed it.

@jonathom
Copy link
Member Author

all changes from review have been added.

@m-mohr m-mohr merged commit ed3df2b into master Jul 17, 2021
@m-mohr m-mohr deleted the cb_graphs branch July 17, 2021 15:55
@m-mohr
Copy link
Member

m-mohr commented Jul 17, 2021

Thank you.

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.

2 participants