You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(sadly Github doesn't render such links as code snippets when they are (spoiler) from a different repo, so I'll copy the code here directly for those cases)
Sounds like smart reusing at first, BUT: Because of this, the processes are handled differently than the collections etc., which all have a mutation in the store:
Such mutations are triggered when the store's commit function is called. In the Web Editor, this happens in the discover function that is part of the store's actions:
(the promises in the array are just waited for to resolve and then discarded too)
So how does it even work that the data ends up in the app?! That is because the ProcessRegistry stored in connection.processes is filled as a side-effect of that connection.listProcesses() call. And that is a function in openeo-js-client (!), so the Web Editor relies on the JS Client doing it this way.
_cache(objects){constplainObjects=objects.map(p=>(typeofp.toJSON==='function' ? p.toJSON() : p));this.connection.processes.addAll(plainObjects,this.namespace);// <--- line 274if(!this.cls){for(letiinobjects){objects[i]=this.connection.processes.get(objects[i].id,this.namespace);}}returnobjects;}}
Line 274, that's where the ProcessRegistry is filled that eventually feeds the Processes component in the UI.
I found that extremely hard to understand and I partly wrote this down to get it fully clear to myself (and not forget it again), partly because I mentioned the ignored value to Matthias and he told me I should note it in an issue here, and partly because I find that the storing should be a bit more explicit, ideally through a cx.commit('processes', ...) to the Vuex store.
The text was updated successfully, but these errors were encountered:
Unfortunately, this difficulty comes from how the different parts (Vue components and Model Builder, JS Client, Web Editor) play together. There's no easy solution for this except if we start to rewrite the whole stack, which will not happen anytime soon due to limited funding. We can keep this open for reference, but I don't expect an implementation anytime soon.
I fully understand this is a complex, evolved architecture that's not going to be refactored quickly, especially not while it doesn't cause 'actual' problems.
But maybe this is an easy fix for the Web Editor part:
Couldn't the JS client explicitly return the ProcessRegistry, which the Web Editor then stores in this.processes through a mutation that is triggered via cx.commit('processes', processRegistryFromJsClient)?
I can't tell without further investigation. There are so many side-effects that apply for the processes so that all changes need to be taken with care.
Nothing users would care about, just something I noticed under the hood:
The data fed to the
Processes
component in theDiscoveryToolbar
is retrieved from theallProcesses
computed property:openeo-web-editor/src/components/DiscoveryToolbar.vue
Line 30 in 7600f8d
which returns:
openeo-web-editor/src/components/DiscoveryToolbar.vue
Lines 125 to 127 in 7600f8d
which comes from the Vuex Store:
openeo-web-editor/src/components/DiscoveryToolbar.vue
Line 112 in 7600f8d
So far so good.
In this store, however,
processes
is not a direct value of the state, but a getter:openeo-web-editor/src/store/index.js
Line 61 in 7600f8d
openeo-web-editor/src/store/index.js
Lines 109 to 118 in 7600f8d
which uses the
connection
, where theprocesses
property holds aProcessRegistry
:https://github.com/Open-EO/openeo-js-client/blob/6d0e09bd3373870b6538628518c3c3167bd8070f/src/connection.js#L97
(sadly Github doesn't render such links as code snippets when they are (spoiler) from a different repo, so I'll copy the code here directly for those cases)
Sounds like smart reusing at first, BUT: Because of this, the processes are handled differently than the collections etc., which all have a
mutation
in the store:openeo-web-editor/src/store/index.js
Lines 332 to 347 in 7600f8d
Such mutations are triggered when the store's
commit
function is called. In the Web Editor, this happens in thediscover
function that is part of the store'sactions
:openeo-web-editor/src/store/index.js
Line 132 in 7600f8d
openeo-web-editor/src/store/index.js
Lines 178 to 182 in 7600f8d
For the processes, this
cx.commit
is missing -- see, nothing is done with the value returned bylistProcesses()
:openeo-web-editor/src/store/index.js
Lines 189 to 192 in 7600f8d
(the promises in the array are just waited for to resolve and then discarded too)
So how does it even work that the data ends up in the app?! That is because the
ProcessRegistry
stored inconnection.processes
is filled as a side-effect of thatconnection.listProcesses()
call. And that is a function in openeo-js-client (!), so the Web Editor relies on the JS Client doing it this way.This is the whole function:
https://github.com/Open-EO/openeo-js-client/blob/6d0e09bd3373870b6538628518c3c3167bd8070f/src/connection.js#L349-L352
Cryptic and unexpected, right? The actual call to the backend happens in that
nextPage
:https://github.com/Open-EO/openeo-js-client/blob/6d0e09bd3373870b6538628518c3c3167bd8070f/src/pages.js#L58-L60
But we don't really have to look at what
nextPage
and thuslistProcesses
eventually returns, because as you remember, the value is discarded anyway.The magic is in this little line within
nextPage
:https://github.com/Open-EO/openeo-js-client/blob/6d0e09bd3373870b6538628518c3c3167bd8070f/src/pages.js#L83-L84
I wouldn't have guessed that from reading the code and the comment. Or from looking at that function's implementation in the
Page
class:https://github.com/Open-EO/openeo-js-client/blob/6d0e09bd3373870b6538628518c3c3167bd8070f/src/pages.js#L140-L148
That's because the relevant part is actually in the overriding function of the
ProcessPages
subclass that inherits fromPage
:https://github.com/Open-EO/openeo-js-client/blob/6d0e09bd3373870b6538628518c3c3167bd8070f/src/pages.js#L237
https://github.com/Open-EO/openeo-js-client/blob/6d0e09bd3373870b6538628518c3c3167bd8070f/src/pages.js#L272-L282
Line 274, that's where the
ProcessRegistry
is filled that eventually feeds theProcesses
component in the UI.I found that extremely hard to understand and I partly wrote this down to get it fully clear to myself (and not forget it again), partly because I mentioned the ignored value to Matthias and he told me I should note it in an issue here, and partly because I find that the storing should be a bit more explicit, ideally through a
cx.commit('processes', ...)
to the Vuex store.The text was updated successfully, but these errors were encountered: