-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,58 @@ | ||
# Contributing | ||
|
||
Issues and pull requests are more than welcome. | ||
|
||
|
||
**dev install** | ||
### Development Environment Setup | ||
|
||
```bash | ||
git clone https://github.com/stac-utils/stac-fastapi.git | ||
cd stac-fastapi | ||
python -m pip install -e stac_fastapi/api[dev] | ||
To install the classes in your local Python env, run: | ||
|
||
```shell | ||
pip install -e 'stac_fastapi/elasticsearch[dev]' | ||
``` | ||
|
||
or | ||
|
||
```shell | ||
pip install -e 'stac_fastapi/opensearch[dev]' | ||
``` | ||
|
||
**pre-commit** | ||
### Pre-commit | ||
|
||
This repo is set to use `pre-commit` to run *ruff*, *pydocstring* and mypy when committing new code. | ||
Install [pre-commit](https://pre-commit.com/#install). | ||
|
||
```bash | ||
Prior to commit, run: | ||
|
||
```shell | ||
pre-commit install | ||
``` | ||
pre-commit run --all-files | ||
``` | ||
|
||
### Docs | ||
### Testing | ||
|
||
```bash | ||
git clone https://github.com/stac-utils/stac-fastapi.git | ||
cd stac-fastapi | ||
python pip install -e stac_fastapi/api["docs"] | ||
```shell | ||
make test | ||
``` | ||
Test against OpenSearch only | ||
|
||
Hot-reloading docs: | ||
|
||
```bash | ||
$ mkdocs serve -f docs/mkdocs.yml | ||
```shell | ||
make test-opensearch | ||
``` | ||
|
||
To manually deploy docs (note you should never need to do this because GitHub | ||
Actions deploys automatically for new commits.): | ||
Test against Elasticsearch only | ||
|
||
```shell | ||
make test-elasticsearch | ||
``` | ||
|
||
```bash | ||
Create API documentations | ||
$ pdocs as_markdown \ | ||
--output_dir docs/src/api/ \ | ||
--exclude_source \ | ||
--overwrite \ | ||
stac_fastapi.opensearch | ||
### Docs | ||
|
||
# deploy | ||
$ mkdocs gh-deploy -f docs/mkdocs.yml | ||
``` | ||
```shell | ||
make docs | ||
``` | ||
|
||
Hot-reloading docs locally: | ||
|
||
```shell | ||
mkdocs serve -f docs/mkdocs.yml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,3 @@ | ||
# Tips and Tricks | ||
|
||
This page contains a few 'tips and tricks' for getting **stac-fastapi** working in various situations. | ||
|
||
## Get stac-fastapi working with CORS | ||
|
||
CORS (Cross-Origin Resource Sharing) support may be required to use stac-fastapi in certain situations. | ||
For example, if you are running [stac-browser](https://github.com/radiantearth/stac-browser) to browse the STAC catalog created by **stac-fastapi**, then you will need to enable CORS support. | ||
To do this, edit your backend's `app.py` and add the following import: | ||
|
||
```python | ||
from fastapi.middleware.cors import CORSMiddleware | ||
``` | ||
|
||
and then edit the `api = StacApi(...` call to add the following parameter: | ||
|
||
```python | ||
middlewares=[lambda app: CORSMiddleware(app, allow_origins=["*"])] | ||
``` | ||
|
||
If needed, you can edit the `allow_origins` parameter to only allow CORS requests from specific origins. | ||
|
||
## Enable the Context extension | ||
|
||
The Context STAC extension provides information on the number of items matched and returned from a STAC search. | ||
This is required by various other STAC-related tools, such as the pystac command-line client. | ||
To enable the extension, edit your backend's `app.py` and add the following import: | ||
|
||
```python | ||
from stac_fastapi.extensions.core.context import ContextExtension | ||
``` | ||
|
||
and then edit the `api = StacApi(...` call to add `ContextExtension()` to the list given as the `extensions` parameter. | ||
This page contains a few 'tips and tricks' for working with **sfeos**. |