https://github.com/britishgeologicalsurvey/pyagsapi

pyagsapi - An AGS Utilities API with AGS v4.x Schema Validation & Converter for .ags<-->.xslx files

https://github.com/britishgeologicalsurvey/pyagsapi

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.3%) to scientific vocabulary

Keywords

docker docker-image fastapi python
Last synced: 5 months ago · JSON representation

Repository

pyagsapi - An AGS Utilities API with AGS v4.x Schema Validation & Converter for .ags<-->.xslx files

Basic Info
Statistics
  • Stars: 18
  • Watchers: 5
  • Forks: 2
  • Open Issues: 20
  • Releases: 52
Topics
docker docker-image fastapi python
Created almost 5 years ago · Last pushed 6 months ago
Metadata Files
Readme License

README.md

pyagsapi - AGS File Utilities API

GitHub release (latest by date) GitHub Release Date GitHub tag (latest by date) GitHub Workflow Status (with branch) GitHub Workflow Status (with branch) GitHub language count GitHub top language GitHub code size in bytes GitHub repo size GitHub GitHub commit activity GitHub commits since tagged version GitHub last commit GitHub contributors

A HTTP API for the AGS Python library.

It can:

  • Validate AGS files to v4.x of the AGS data format standard
  • Validate AGS files for submission to the National Geoscience Data Center (NGDC)
  • Extract geojson from submitted files and plot on a map
  • Convert between AGS format files and spreadsheet files .ags <-> .xlsx
  • Download PDF logs of existing files within the National Geoscience Data Centre

It is built on the FastAPI framework, using the official FastAPI Docker image.

The core Python API provides the functionality to validate and convert AGS geotechnical data. From here, standard Python web frameworks like Uvicorn and Starlette provide the web API/wrapper atop the core Python API.

BGS Deployed Instance available at: https://agsapi.bgs.ac.uk/

Quick start

Docker

The simplest way to run the validation service is via Docker:

docker run -p 80:80 --name pyagsapi ghcr.io/britishgeologicalsurvey/pyagsapi:latest

Navigate to http://localhost to see the landing page or http://localhost/docs to see the API documentation via the Swagger interface.

The latest tag reflects the current state of the main branch of the repository. It may have breaking changes. Use versions from tagged Releases to fix the version in deployment pipelines. Available tags are listed in the Container Registry.

Setting the root_path

If you are running behind a proxy, you may need to set the root_path using the PYAGSAPI_ROOT_PATH environment variable:

docker run -p 80:80 -e PYAGSAPI_ROOT_PATH="/pyagsapi" --name pyagsapi ghcr.io/britishgeologicalsurvey/pyagsapi

This will ensure that all references to self in responses, and all Swagger and REDOC documentation, include the correct path.

From Source

pyagsapi targets Python >= 3.13.

bash python -m venv pyagsapi source pyagsapi/bin/activate git clone https://github.com/BritishGeologicalSurvey/pyagsapi.git cd pyagsapi pip install -r requirements.txt uvicorn app.main:app

Development

The main repo for this project is https://github.com/BritishGeologicalSurvey/pyagsapi/.

Please raise any feature requests, issues or pull requests against this repository.

Running locally

AGS Validator is written in Python and based on the FastAPI framework. It runs on the Uvicorn ASGI server.

Use the instructions above to run the API locally.

By default, the API is served at http://localhost:8000.

Running tests

Use the following to run the tests:

bash pip install -r requirements_dev.txt export PYTHONPATH=. pytest -vs test

The test environment is configured so that adding --pdb to the test command will start an IPython debugger session in the event of test failure.

Updating dependencies

We are using pip-tools to create a pinned list of all dependencies from the ones that we need to specify.

To refresh the dependency list, update requirements.in and requirements-dev.in then run the following:

bash pip-compile -o requirements.txt requirements.in pip-compile -o requirements_dev.txt requirements_dev.in

The updated requirements files must be edited to remove reference to the Nexus mirror before they can then be committed.

GUI Customisation

To ammend the GUI HTML we recommend running via Docker using your own Dockerfile like the below to COPY in your own templates.

``` FROM ghcr.io/britishgeologicalsurvey/pyagsapi:2.0

COPY content/static /app/app/static COPY content/templates /app/app/templates ```

Container Registry

Containers for the application are hosted in the GitHub Container Registry

Every push to main branch commits builds pyagsapi:latest.

Push Tagged Releases with ^v?[0-9]+[.][0-9]+([.][0-9])? (v* == v2.0) builds pyagsapi:2.0 (the "v" gets dropped for the tag).

You can also push release candidates using the format /^v?[0-9]+[.][0-9]+([.][0-9])?\-rc/ e.g. v3.1.1-rc builds pyagsapi:3.1.1-rc

Example Files

Files in https://github.com/BritishGeologicalSurvey/pyagsapi/tree/main/test/files/real are a collection of real AGS files which have been submitted to the BGS and are available under OGL, we have included them here as example files for testing pyagsapi.

Licence

pyagsapi was created by and is maintained by the British Geological Survey. It is distributed under the LGPL v3.0 licence. Copyright: © BGS / UKRI 2021

Contains data supplied by Natural Environment Research Council.

Contains public sector information licensed under the Open Government Licence v3.0

Owner

  • Name: British Geological Survey
  • Login: BritishGeologicalSurvey
  • Kind: organization
  • Email: enquiries@bgs.ac.uk
  • Location: Keyworth, Nottinghamshire

The British Geological Survey is responsible for advising the UK government on geoscience and providing impartial advice to industry, academia and the public.

GitHub Events

Total
  • Issues event: 8
  • Watch event: 4
  • Member event: 1
  • Issue comment event: 5
  • Push event: 16
  • Pull request event: 4
  • Create event: 3
Last Year
  • Issues event: 8
  • Watch event: 4
  • Member event: 1
  • Issue comment event: 5
  • Push event: 16
  • Pull request event: 4
  • Create event: 3

Dependencies

requirements.txt pypi
  • Fiona ==1.8.20
  • Jinja2 ==3.0.1
  • Shapely ==1.7.1
  • aiofiles ==0.7.0
  • colorlog ==5.0.1
  • fastapi ==0.68.0
  • geopandas ==0.9.0
  • h11 ==0.12.0
  • numpy ==1.21.2
  • pyproj ==3.2.1
  • python-ags4 ==0.3.6
  • python-multipart ==0.0.5
  • shortuuid ==1.0.1
  • uvicorn ==0.15.0
requirements_dev.txt pypi
  • flake8 * development
  • freezegun ==1.1.0 development
  • httpx ==0.19.0 development
  • ipdb * development
  • ipython * development
  • pytest * development
  • pytest-asyncio ==0.15.1 development
  • requests * development
  • requests-toolbelt ==0.9.1 development
.github/workflows/lint_and_test.yml actions
  • actions/checkout v3.3.0 composite
  • actions/setup-python v4.5.0 composite
.github/workflows/main.yml actions
  • actions/checkout v3.3.0 composite
.github/workflows/pages.yml actions
  • actions/cache v3 composite
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
Dockerfile docker
  • tiangolo/uvicorn-gunicorn-fastapi python3.11-slim-2023-02-20 build