Skip to content

Commit

Permalink
add option to override rootpath, if api is deployed on path
Browse files Browse the repository at this point in the history
also option to set analysed enpoint as env var
  • Loading branch information
pvgenuchten committed Jun 14, 2024
1 parent 197a91b commit cffd283
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 130 deletions.
46 changes: 0 additions & 46 deletions .gitlab-ci.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .releaserc.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions CHANGELOG.md

This file was deleted.

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ RUN apt-get update && apt-get install --yes \

RUN adduser --uid 1000 --gecos '' --disabled-password linky

ENV OGCAPI_URL=http://localhost
ENV OGCAPI_COLLECTION=metadata:main
ENV ROOTPATH=/
ENV POSTGRES_HOST=host.docker.internal
ENV POSTGRES_PORT=5432
ENV POSTGRES_DB=postgres
Expand Down
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# isric instance

- forked from https://github.com/soilwise-he/link-liveliness-assessment
- add gitlab ci script
- in harbor soilwise project

# OGC API - Records; link liveliness assessment

A component which evaluates for a set of metadata records (describing either data or knowledge sources), if:
Expand Down Expand Up @@ -34,6 +28,12 @@ The benefit of latter is that it provides more information then a simple ping to

OGC is in the process of adopting the [OGC API - Records](https://github.com/opengeospatial/ogcapi-records) specification. A standardised API to interact with Catalogues. The specification includes a datamodel for metadata. This tool assesses the linkage section of any record in an OGC API - Records.

Set the endpoint to be analysed as 2 environment variables

```
export OGCAPI_URL=https://soilwise-he.containers.wur.nl/cat/
export OGCAPI_COLLECTION=metadata:main
```

## Source Code Brief Desrciption

Expand All @@ -55,11 +55,21 @@ More specifically the following parameters must be specified

## API
The api.py file creates a FastAPI in order to retrieve links statuses.
Run the command below
* python -m uvicorn api:app --reload --host 0.0.0.0 --port 8000
Run the command below:
```
python -m uvicorn api:app --reload --host 0.0.0.0 --port 8000
```
To view the service of the FastAPI on [http://127.0.0.1:8000/docs]

# Docker
## Deploy `linky` at a path

You can set `ROOTPATH` env var to run the api at a path (default is at root)

```
export ROOTPATH=/linky
```

## Docker
A Docker instance must be running for the linkchecker command to work.

## CI/CD
Expand Down
9 changes: 5 additions & 4 deletions src/linkchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

# base catalog

base = "https://soilwise-he.containers.wur.nl/cat/"
base = os.environ.get("OGCAPI_URL") or "https://demo.pycsw.org/gisdata"
collection = os.environ.get("OGCAPI_COLLECTION") or "metadata:main"

# Remove comment'
catalogue_json_url = base + "collections/metadata:main/items?f=json"
catalogue_json_url = base + "collections/" + collection + "/items?f=json"

def setup_database():
# Connect to the database
Expand Down Expand Up @@ -132,7 +133,7 @@ def main():
total_pages, numbers_returned = get_pagination_info(catalogue_json_url)

# Base URL
base_url = base + 'collections/metadata:main/items?offset='
base_url = base + 'collections/' + collection + '/items?offset='

# Generate URLs for each page
urls = [base_url + str(i * numbers_returned) + "&f=html" for i in range(total_pages)]
Expand All @@ -146,7 +147,7 @@ def main():

# Define the formats to be removed
formats_to_remove = [
'collections/metadata:main/items?offset',
'collections/' + collection + '/items?offset',
'?f=json'
]

Expand Down

0 comments on commit cffd283

Please sign in to comment.