Skip to content

Commit

Permalink
Merge pull request #2 from LimnoTech/develop
Browse files Browse the repository at this point in the history
v0.0.2 release
  • Loading branch information
xaviernogueira committed Jun 7, 2023
2 parents adb68c3 + 5b15b70 commit bf692f7
Show file tree
Hide file tree
Showing 18 changed files with 19,197 additions and 1,120 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
**.pyc
**.tmp
**.log
dist/**
src/catalog_to_xpublish.egg-info/**
.vscode/**
src/catalog_to_xpublish/practice_server.py
DEV_NOTES.md
42 changes: 37 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,39 @@ This repository enables one to spin-up a `fastapi`/`xpublish` server from either
* FastAPI documentation via `/docs` (for Swagger) or `/redoc` for Redoc. Note that `xpublish` endpoints will only appear at a catalog level containing servable datasets.
* After a `datasets/{dataset_id}` is selected, one can also use any additional endpoints added via `xpublish` plugins. These endpoints will appear in the API documentation endpoint `/docs`.

## Logging
By default, `catalog_to_xpublish` will log to the console at the "INFO" level.

One can change logging behaviors by passing in a `config_logging_dict` argument to `catalog_to_xpublish.create_app()` which contains any of following keys:
* `log_level`: The logging level. Default is "INFO".
* `log_file_path`: The path to a log file. Default is `None`.
* `date_format`: The date format for log messages. Default is `'%Y-%m-%dT%H:%M:%S'`.
* `log_format`: The log message format. Default is `'[%(asctime)s] %(levelname)s - %(message)s'`.
* `stream_handlers`: Stream handler(s) to use (can be a list). Default is is console.

For example, here is how one can log at the DEBUG level to an existing `logging.StreamHandler` and log file:
```python
import catalog_to_xpublish
import logging

# identify a catalog
CATALOG_URL = 'https://code.usgs.gov/wma/nhgf/stac/-/raw/main/catalog2/catalog.json'

# set logging config
existing_stream_handler: logging.StreamHandler = ...
LOGGING_CONFIG = {
'log_level': 'DEBUG',
'log_file_path': 'my_log_file.log',
'stream_handlers': [existing_stream_handler],
}

# create FastAPI app instance
app = catalog_to_xpublish.create_app(
catalog_path=CATALOG_URL,
catalog_type='stac',
config_logging_dict=LOGGING_CONFIG,
)
```

## Contributing
### General
Expand Down Expand Up @@ -182,11 +215,10 @@ This process is demonstrated below:
) -> None:
"""An init that contains a call to server_functions.add_base_routes(self)"""
# add routes for all base CatalogRouter endpoints/class functions
add_base_routes(self)
...

def get_catalog_ui(self) -> HTMLResponse:
"""Returns the catalog ui."""
super().__init__(
catalog_endpoint_obj=catalog_endpoint_obj,
prefix=prefix,
)
...

def list_sub_catalogs(self) -> List[str]:
Expand Down
24 changes: 19 additions & 5 deletions dev_environment.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: catalog_to_xpublish_dev
channels:
- conda-forge
- pyviz
- nodefaults

# a minimal environment for Catalog-To-Xpublish
# a larger environment for Catalog-To-Xpublish to support development and demos
dependencies:
- python =3.11

# For data processing
- xpublish
- xarray
- dask

Expand All @@ -20,11 +22,27 @@ dependencies:
- fsspec
- s3fs
- h5netcdf
- h5pyd
- zarr

# xpublish plugins
- xpublish-opendap
- xpublish-edr

# for demo
- jupyterlab
- ipympl
- nodejs

# get holoviews libs from pyviz
- holoviews >=1.12.0
- hvplot
- geoviews >=1.6.2 # pinned to avoid this issue: https://github.com/holoviz/geoviews/issues/334

# Dev tools: Language Server Protocol (LSP)
- python-lsp-server # LSP extension for Python (pylsp), including:
- pylsp-mypy # MyPy type checking for Python >=3.7.
- jupyterlab-lsp
- pydantic

# Dev tools: For testing and pre-commit hooks
Expand All @@ -36,7 +54,3 @@ dependencies:
- conda-build
- conda-libmamba-solver
- pip

# we get the latest version of xpublish from github
- pip:
- git+https://github.com/xpublish-community/xpublish.git
5 changes: 1 addition & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:

# For data processing
- xarray
- xpublish
- dask

# For catalog access
Expand All @@ -32,7 +33,3 @@ dependencies:
- conda-build
- conda-libmamba-solver
- pip

# we get the latest version of xpublish from github
- pip:
- git+https://github.com/xpublish-community/xpublish.git
Loading

0 comments on commit bf692f7

Please sign in to comment.