Skip to content

Commit

Permalink
Local dev setup with vscode & some tiny fixes (#128)
Browse files Browse the repository at this point in the history
* some tiny fixes

* add local dev setup
  • Loading branch information
mmacata authored Dec 9, 2021
1 parent 6389742 commit 0feb43d
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 26 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@ docs/_build/*
cover/*
MANIFEST

.vscode
venv

24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations": [
{
"name": "Docker: Python - Flask",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/src/openeo_grass_gis_driver"
}
],
"projectType": "flask"
},
"dockerServerReadyAction": {
"action": "openExternally",
"pattern": "Running on (https?://\\S+|[0-9]+)",
"uriFormat": "%s://localhost:%s/api/v1.0/collections"
}
}
]
}
48 changes: 48 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "docker-build",
"label": "docker-build",
"platform": "python",
"dockerBuild": {
"tag": "openeograssgisdriver:latest",
"dockerfile": "${workspaceFolder}/docker/dev/Dockerfile",
"context": "${workspaceFolder}"
// "pull": true
}
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": [
"docker-build"
],
"python": {
"args": [
"run",
"--no-debugger",
// "--no-reload",
"--host",
"0.0.0.0",
"--port",
"5000"
],
"module": "flask"
// "file": "dev.py"
},
"dockerRun": {
"remove": true,
// network host is needed when connecting to a local actinia
// while not using docker-compose network
"network": "host",
"volumes": [{
"localPath": "${workspaceFolder}",
"containerPath": "/src/openeo_grass_gis_driver",
"permissions": "rw"
}]
},

}
]
}
23 changes: 23 additions & 0 deletions docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM mundialis/openeo-grassgis-driver:latest as base

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=openeo_grass_gis_driver.main
ENV FLASK_ENV=development
ENV FLASK_DEBUG=1
ENV DEFAULT_CONFIG_PATH=/src/openeo_grass_gis_driver/config

RUN apk add make git

RUN pip3 uninstall openeo-grass-gis-driver -y

COPY . /src/openeo_grass_gis_driver/
COPY config/sample.ini /src/openeo_grass_gis_driver/config/config.ini

WORKDIR /src/openeo_grass_gis_driver/
RUN pip3 install -e .

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "openeo_grass_gis_driver.main"]
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package_dir =
=src
# Add here dependencies of your project (semicolon-separated), e.g.
# install_requires = numpy; scipy
install_requires =
install_requires = colorlog; python-json-logger;
# Add here test requirements (semicolon-separated)
tests_require = pytest; pytest-cov

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ def __init__(self, config: ActiniaConfig = None):

self.host = config.HOST
self.port = config.PORT
self.base_url = "%(host)s:%(port)s/api/v1" % {
"host": self.host, "port": self.port}
self.version = config.VERSION
self.base_url = "%(host)s:%(port)s/api/%(version)s" % {
"host": self.host, "port": self.port,
"version": self.version}
self.auth = (config.USER, config.PASSWORD)
self.user = config.USER

Expand Down
3 changes: 3 additions & 0 deletions src/openeo_grass_gis_driver/actinia_processing/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ACTINIA:
LOCATIONS = ["nc_spm_08", "utm32n", "latlong_wgs84"]
USER = "openeo"
PASSWORD = "EeMob0la"
VERSION = "v2"
# The database file that stores the graphs
GRAPH_DB = "%s/.graph_db_file.sqlite" % os.environ["HOME"]
# The database file that stores the jobs
Expand Down Expand Up @@ -77,6 +78,8 @@ def __init__(self):
ACTINIA.USER = config.get("ACTINIA", "USER")
if config.has_option("ACTINIA", "PASSWORD"):
ACTINIA.PASSWORD = config.get("ACTINIA", "PASSWORD")
if config.has_option("ACTINIA", "VERSION"):
ACTINIA.VERSION = config.get("ACTINIA", "VERSION")
if config.has_option("ACTINIA", "GRAPH_DB"):
ACTINIA.GRAPH_DB = config.get("ACTINIA", "GRAPH_DB")
if config.has_option("ACTINIA", "TOKEN_DB"):
Expand Down
45 changes: 24 additions & 21 deletions src/openeo_grass_gis_driver/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,30 @@ def get(self):
log.warning("Couldn't get STAC collections from actinia")
stac_collections = []

for i in stac_collections['collections']:
try:
title = i['title']
except Exception:
title = i['id']
try:
license = i['license']
except Exception:
license = "proprietary"
try:
description = i['description']
except Exception:
description = "STAC collection registered in actinia"

ds = CollectionEntry(
id=i['id'],
title=title,
license=license,
description=description
)
COLLECTIONS_LIST.append(ds)
if (type(stac_collections) is list and
len(stac_collections) > 0):

for i in stac_collections['collections']:
try:
title = i['title']
except Exception:
title = i['id']
try:
license = i['license']
except Exception:
license = "proprietary"
try:
description = i['description']
except Exception:
description = "STAC collection registered in actinia"

ds = CollectionEntry(
id=i['id'],
title=title,
license=license,
description=description
)
COLLECTIONS_LIST.append(ds)

c = Collection(collections=COLLECTIONS_LIST)
return c.as_response(http_status=200)

0 comments on commit 0feb43d

Please sign in to comment.