quangis / quangis-workflow

Tools to describe GIS workflows semantically, and to generate them. Includes the core concept transformation algebra (CCT).
GNU General Public License v3.0
1 stars 0 forks source link

"Number of inputs doesn't correspond" #23

Closed nsbgn closed 1 year ago

nsbgn commented 1 year ago

APE generates the following workflow:

@prefix abstr: <https://quangis.github.io/tool/abstract#> .
@prefix ccd: <http://geographicknowledge.de/vocab/CoreConceptData.rdf#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix wf: <http://geographicknowledge.de/vocab/Workflow.rdf#> .
@prefix wfgen: <https://quangis.github.io/workflows/generated/> .

wfgen:CoreConceptQ.LayerA.NominalA-ObjectQ.PointA.PlainNominalA--ObjectQ.PlainVectorRegionA.IRA1 a wf:Workflow ;
    wf:edge [ wf:applicationOf abstr:SummaryStatistics3 ;
            wf:inputx _:N18bf9ac78f664c6683ce160b32d15068 ;
            wf:output _:Nc3f304f31f374e76a31d2377c9ad50fd ],
        [ wf:applicationOf abstr:ZonalStatisticsMeanRatio ;
            wf:inputx _:N6b1d2d73fd6f4f29b54d3b95cc892a0b,
                _:Nc3f304f31f374e76a31d2377c9ad50fd ;
            wf:output [ a ccd:IRA,
                        ccd:ObjectQ,
                        ccd:PlainVectorRegionA ;
                    rdfs:label "ObjectQ, PlainVectorRegionA, IRA" ] ],
        [ wf:applicationOf abstr:GenerateNearTable ;
            wf:inputx _:Nbb6ebfd31c134f9db6381d93be2dc347 ;
            wf:output _:N18bf9ac78f664c6683ce160b32d15068 ] ;
    wf:source _:N6b1d2d73fd6f4f29b54d3b95cc892a0b,
        _:Nbb6ebfd31c134f9db6381d93be2dc347 .

_:N18bf9ac78f664c6683ce160b32d15068 a ccd:ObjectQ,
        ccd:PlainRatioA,
        ccd:PointA ;
    rdfs:label "ObjectQ, PointA, PlainRatioA" .

_:N6b1d2d73fd6f4f29b54d3b95cc892a0b a ccd:ERA,
        ccd:FieldQ,
        ccd:RasterA ;
    rdfs:label "FieldQ, RasterA, ERA" .

_:Nbb6ebfd31c134f9db6381d93be2dc347 a ccd:ObjectQ,
        ccd:PlainNominalA,
        ccd:PointA ;
    rdfs:label "ObjectQ, PointA, PlainNominalA" .

_:Nc3f304f31f374e76a31d2377c9ad50fd a ccd:ObjectQ,
        ccd:PlainRatioA,
        ccd:PlainVectorRegionA ;
    rdfs:label "ObjectQ, PlainVectorRegionA, PlainRatioA" .

This leads to the following error when applying the input hack of #18:

Traceback (most recent call last):
  File "/home/nsbg/venv/lib/python3.11/site-packages/doit/action.py", line 461, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nsbg/quangis-workflow/dodo.py", line 377, in action
    solution = repo.input_permutation_hack(orig)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nsbg/quangis-workflow/quangis/tools/repo.py", line 354, in input_permutation_hack
    raise RuntimeError(
RuntimeError: Number of inputs doesn't correspond for abstr:GenerateNearTable

This makes sense, because abstr:GenerateNearTable has two inputs, not one. This is indeed reflected in the tools.json file that's handed to APE:

        {
            "id": "https://quangis.github.io/tool/abstract#GenerateNearTable",
            "label": "GenerateNearTable",
            "taxonomyOperations": [
                "https://quangis.github.io/tool/abstract#GenerateNearTable"
            ],
            "inputs": [
                {
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#LayerA": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#PointA"
                    ],
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#CoreConceptQ": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#ObjectQ"
                    ],
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#NominalA": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#NominalA"
                    ]
                },
                {
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#LayerA": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#PointA"
                    ],
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#CoreConceptQ": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#ObjectQ"
                    ],
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#NominalA": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#NominalA"
                    ]
                }
            ],
            "outputs": [
                {
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#LayerA": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#PointA"
                    ],
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#CoreConceptQ": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#ObjectQ"
                    ],
                    "http://geographicknowledge.de/vocab/CoreConceptData.rdf#NominalA": [
                        "http://geographicknowledge.de/vocab/CoreConceptData.rdf#PlainRatioA"
                    ]
                }
            ]
        }

This could be either an issue in the interface with APE at ape.py, or an issue with APE itself.

Note also that the issue is not always reproducible because there's a nondeterministic aspect to it --- multiple workflows fit the bill.

nsbgn commented 1 year ago

Almost certainly because the two inputs are the same type, and so APE just reuses the same type. I will make it even more hacky and just duplicate the inputs.