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

Removed datamodel-code-generator from dev requirements #1370

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,6 @@ To run all tests, simply run ``pytest`` in the repository. To run a specific te
run ``pytest tests/test_api.py``, for example.


CQL extension lifecycle
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing this entire section? Maybe it's better for DX to remove only Model generation and How to merge and add a paragraph How to hack the models, what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you envision as being the content of this alternative How to hack the models section?

In my opinion it would likely make sense if you'd still like to recommend a workflow like the autogeneration of models using datamodel-code-generator and then some manual tweaking. But I don't see much value in it, as the models already exist and have modifications, so it seems more likely that further changes will not restart from scratch - in which case, it seems to me that How to hack the models is not so different from how to develop pygeoapi as a whole.

But maybe I'm missing the point 😅 ?

-----------------------

Limitations
^^^^^^^^^^^

This workflow is valid only for the `CQL-JSON` format.

Schema
^^^^^^

The Common Query Language (CQL) is the part 3 of the standard OGC API - Features. This extension has its specification available at
`OGC API - Features - Part 3: Filtering and the Common Query Language (CQL) <https://portal.ogc.org/files/96288>`_ and the schema exists in development at
`cql.json <https://portal.ogc.org/files/96288#cql-json-schema>`_.

Model generation
^^^^^^^^^^^^^^^^

pygeoapi uses a class-based Python model interface to translate the schema into Python objects defined by `pydantic <https://docs.pydantic.dev/>`_ models.
The model is generated with the pre-processing of the schema through the utility ``datamodel-codegen``:

.. code-block:: bash

# Generate from local downloaded json schema file
datamodel-codegen --input ~/Download/cql-schema.json --input-file-type jsonschema --output ./pygeoapi/models/cql_update.py --class-name CQLModel

How to merge
^^^^^^^^^^^^

Once the new pydantic models have been generated then the content of the Python file ``cql_update.py`` can be used to replace the old classes within the ``cql.py`` file.
Update everything above the function ``get_next_node`` and then verify if the tests for the CQL are still passing, for example ``test_post_cql_json_between_query``
in ``tests/test_elasticsearch__provider.py``.

Working with Spatialite on OSX
------------------------------

Expand Down
3 changes: 0 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Flask-based CORS setup
flask_cors

# Generate pydantic models from json schema
datamodel-code-generator

# testing
pytest
pytest-cov
Expand Down