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

Use the JSON interface to qgis_process when available #44

Closed
paleolimbot opened this issue Apr 17, 2021 · 5 comments
Closed

Use the JSON interface to qgis_process when available #44

paleolimbot opened this issue Apr 17, 2021 · 5 comments

Comments

@paleolimbot
Copy link
Collaborator

Right now qgis_run_algorithm() generates command-line arguments in the form --ARG=VALUE, which can't be used for all input types. The JSON interface should be used when available!

@paleolimbot
Copy link
Collaborator Author

Just as an update...this one is really important for implementing an interface to all the algorithms. I think that the LTR (3.16) contains the ability to use JSON here, so we should be clear to use it. I plan to spend my open source time in September/October spiffing up this package (ahead of the FOSS4G talk!).

nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Dec 15, 2021
specified as a JSON object passed via stdin to qgis_process

This provides a mechanism to support complex input parameters
for algorithms, and a way for qgis_process to gain support
for parameter types which are themselves specified as a dictionary
type object.

To indicate that parameters will be specified via stdin then
the qgis_process command must follow the format

    qgis_process run algid -

(with a trailing - in place of the usual arguments list).

The JSON object must contain an "inputs" key, which is a map
of the input parameter values.

E.g.

    echo "{"inputs": {\"INPUT\": \"my_shape.shp\", DISTANCE: 5}}" | qgis_process run native:buffer -

Specifying input parameters via stdin implies automatically
the --json output format for results.

One big motivation behind this enhancement is to provide a way for
the qgisprocess R libraries to support parameter types such as
aggregates.

Refs r-spatial/qgisprocess#56
Refs r-spatial/qgisprocess#44

Sponsored by the Research Institute for Nature and Forest, Flemish Govt
@nyalldawson
Copy link

Just like #56, this should be possible following qgis/QGIS#46497

nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Dec 15, 2021
specified as a JSON object passed via stdin to qgis_process

This provides a mechanism to support complex input parameters
for algorithms, and a way for qgis_process to gain support
for parameter types which are themselves specified as a dictionary
type object.

To indicate that parameters will be specified via stdin then
the qgis_process command must follow the format

    qgis_process run algid -

(with a trailing - in place of the usual arguments list).

The JSON object must contain an "inputs" key, which is a map
of the input parameter values.

E.g.

    echo "{"inputs": {\"INPUT\": \"my_shape.shp\", DISTANCE: 5}}" | qgis_process run native:buffer -

Specifying input parameters via stdin implies automatically
the --json output format for results.

One big motivation behind this enhancement is to provide a way for
the qgisprocess R libraries to support parameter types such as
aggregates.

Refs r-spatial/qgisprocess#56
Refs r-spatial/qgisprocess#44

Sponsored by the Research Institute for Nature and Forest, Flemish Govt
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Dec 16, 2021
specified as a JSON object passed via stdin to qgis_process

This provides a mechanism to support complex input parameters
for algorithms, and a way for qgis_process to gain support
for parameter types which are themselves specified as a dictionary
type object.

To indicate that parameters will be specified via stdin then
the qgis_process command must follow the format

    qgis_process run algid -

(with a trailing - in place of the usual arguments list).

The JSON object must contain an "inputs" key, which is a map
of the input parameter values.

E.g.

    echo "{"inputs": {\"INPUT\": \"my_shape.shp\", DISTANCE: 5}}" | qgis_process run native:buffer -

Specifying input parameters via stdin implies automatically
the --json output format for results.

One big motivation behind this enhancement is to provide a way for
the qgisprocess R libraries to support parameter types such as
aggregates.

Refs r-spatial/qgisprocess#56
Refs r-spatial/qgisprocess#44

Sponsored by the Research Institute for Nature and Forest, Flemish Govt
nyalldawson added a commit to qgis/QGIS that referenced this issue Dec 20, 2021
specified as a JSON object passed via stdin to qgis_process

This provides a mechanism to support complex input parameters
for algorithms, and a way for qgis_process to gain support
for parameter types which are themselves specified as a dictionary
type object.

To indicate that parameters will be specified via stdin then
the qgis_process command must follow the format

    qgis_process run algid -

(with a trailing - in place of the usual arguments list).

The JSON object must contain an "inputs" key, which is a map
of the input parameter values.

E.g.

    echo "{"inputs": {\"INPUT\": \"my_shape.shp\", DISTANCE: 5}}" | qgis_process run native:buffer -

Specifying input parameters via stdin implies automatically
the --json output format for results.

One big motivation behind this enhancement is to provide a way for
the qgisprocess R libraries to support parameter types such as
aggregates.

Refs r-spatial/qgisprocess#56
Refs r-spatial/qgisprocess#44

Sponsored by the Research Institute for Nature and Forest, Flemish Govt
@florisvdh
Copy link
Member

florisvdh commented Feb 21, 2022

QGIS 3.24.0 has been released on GitHub three days ago; it came available in at least the ubuntugis repository this weekend. That's great news, it makes that the latest QGIS release now supports the JSON input method for its command line program qgis_process 🎉. This means that the qgisprocess package now also supports QGIS algorithms with more complex inputs, when using QGIS >= 3.24.0!

Moreover, the QGIS GUI now helps in preparing the specification of algorithm arguments, both for the standard approach with separate arguments, and for the JSON input approach:

  • processing tool dialog: copy as qgis_process command
  • processing tool dialog: copy JSON
  • processing history dialog (after running algorithm in GUI): copy as qgis_process command
  • processing history dialog (after running algorithm in GUI): copy JSON

Thanks @nyalldawson for implementing this in QGIS, thanks @paleolimbot for upgrading qgisprocess to support this! 👏 👏 👏

Below is a screenshot showing where the copying can be done in a processing tool dialog. Note that it's not needed to actually run the processing in the dialog.

afbeelding

Probably this issue can be closed once the new release is officially announced on the QGIS website.

@florisvdh
Copy link
Member

@paleolimbot it looks to me this issue can be closed.

@florisvdh
Copy link
Member

Closing with pleasure - thanks for this amazing stuff @paleolimbot!

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

No branches or pull requests

3 participants