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

Conditional steps #169

Open
tpluscode opened this issue Aug 29, 2023 · 1 comment
Open

Conditional steps #169

tpluscode opened this issue Aug 29, 2023 · 1 comment

Comments

@tpluscode
Copy link
Contributor

Consider a CSVW pipeline which often looks like below, where we remove the csvw: triples.

@prefix code: <https://code.described.at/> .
@prefix p: <https://pipeline.described.at/> .

<transform> a p:Pipeline, p:ReadableObjectMode ;
    p:steps
        [
            p:stepList
                (
                    _:readCsv
                    _:parseCsv
                    _:toDataset
                    _:toObservation
                    _:buildCubeShape
                    _:flatten
                    _:removeCsvwTriples
                    _:generateShapeTarget
                ) ;
        ] ;
.

_:removeCsvwTriples a p:Step ;
    code:implementedBy
        [
            a code:EcmaScriptModule ;
            code:link <node:barnard59-base/filter.js#default> ;
        ] ;
    code:arguments
        (
            [
                a code:EcmaScriptModule ;
                code:link <node:barnard59-csvw/filter.js#excludeCsvwTriples> ;
            ]
        ) ;
.

The simple way to disable a step (skip it) would be to resolve a variable

<transform>
  p:variables [
    p:variable [ p:name "KEEP_CSVW_META" ; p:value false ] ;
  ] ;
.

_:removeCsvwTriples a p:Step ;
+   p:if "KEEP_CSVW_META"^^p:VariableName ;
.

So if KEEP_CSVW_META is truthy, the step will run.

In to make more complex decision, the a function could be used

_:removeCsvwTriples a p:Step ;
+   p:if """
+       async () => {
+         // make a decision in code
+       }
+     """^^code:EcmaScript ;
.

This function would be evaluated once, at the beginning.

@tpluscode
Copy link
Contributor Author

If not too complex, we should implement this in a way that the skipped step if effectively removed from the pipeline. Otherwise a PassThrough would be enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant