Skip to content

Commit

Permalink
Merge pull request #944 from opengisch/QF-3813-dev-sdk
Browse files Browse the repository at this point in the history
Allow development of the SDK alongside QFieldCloud
  • Loading branch information
suricactus authored May 22, 2024
2 parents 253e8e9 + 9e5e7fd commit fbd23ea
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ QFIELDCLOUD_DEFAULT_TIME_ZONE="Europe/Zurich"
# DEFAULT: ""
QFIELDCLOUD_LIBQFIELDSYNC_VOLUME_PATH=""

# QFieldCloud SDK volume path to be mounted by the `worker_wrapper` into `worker` containers.
# If empty value or invalid value, the pip installed version defined in `requirements_libqfieldsync.txt` will be used.
# DEFAULT: ""
QFIELDCLOUD_QFIELDCLOUD_SDK_VOLUME_PATH=""

# The Django development port. Not used in production.
# DEFAULT: 8011
DJANGO_DEV_PORT=8011
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ conf/certbot/*
Pipfile*
**/site-packages
docker-qgis/libqfieldsync
docker-qgis/qfieldcloud-sdk-python
2 changes: 2 additions & 0 deletions docker-app/qfieldcloud/core/views/files_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def get(self, request: Request, projectid: str) -> Response:
path = PurePath(version.key)
filename = str(path.relative_to(*path.parts[:3]))
last_modified = version.last_modified.strftime("%d.%m.%Y %H:%M:%S %Z")
# NOTE ETag is a MD5. But for the multipart uploaded files, the MD5 is computed from the concatenation of the MD5s of each uploaded part.
# TODO make sure when file metadata is in the DB (QF-2760), this is a real md5sum of the current file.
md5sum = version.e_tag.replace('"', "")

version_data = {
Expand Down
5 changes: 5 additions & 0 deletions docker-app/qfieldcloud/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ def before_send(event, hint):
"QFIELDCLOUD_LIBQFIELDSYNC_VOLUME_PATH"
)

# Absolute path on the docker host where `qfieldcloud-sdk-python` is mounted from for development
QFIELDCLOUD_QFIELDCLOUD_SDK_VOLUME_PATH = os.environ.get(
"QFIELDCLOUD_QFIELDCLOUD_SDK_VOLUME_PATH"
)

# Volume name where transformation grids required by `PROJ` are downloaded to
QFIELDCLOUD_TRANSFORMATION_GRIDS_VOLUME_NAME = os.environ.get(
"QFIELDCLOUD_TRANSFORMATION_GRIDS_VOLUME_NAME"
Expand Down
6 changes: 6 additions & 0 deletions docker-app/worker_wrapper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ def _run_docker(
f"{settings.QFIELDCLOUD_LIBQFIELDSYNC_VOLUME_PATH}:/libqfieldsync:ro"
)

# used for local development of QFieldCloud
if settings.QFIELDCLOUD_QFIELDCLOUD_SDK_VOLUME_PATH:
volumes.append(
f"{settings.QFIELDCLOUD_QFIELDCLOUD_SDK_VOLUME_PATH}:/qfieldcloud-sdk-python:ro"
)

# `docker_started_at`/`docker_finished_at` tracks the time spent on docker only
self.job.docker_started_at = timezone.now()
self.job.save(update_fields=["docker_started_at"])
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.override.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
- ${DEBUG_DEBUGPY_WORKER_WRAPPER_PORT:-5679}:5679
environment:
QFIELDCLOUD_LIBQFIELDSYNC_VOLUME_PATH: ${QFIELDCLOUD_LIBQFIELDSYNC_VOLUME_PATH}
QFIELDCLOUD_QFIELDCLOUD_SDK_VOLUME_PATH: ${QFIELDCLOUD_QFIELDCLOUD_SDK_VOLUME_PATH}
volumes:
# mount the source for live reload
- ./docker-app/qfieldcloud:/usr/src/app/qfieldcloud
Expand Down Expand Up @@ -69,6 +70,8 @@ services:
volumes:
# allow local development for `libqfieldsync` if host directory present; requires `PYTHONPATH=/libqfieldsync:${PYTHONPATH}`
- ./docker-qgis/libqfieldsync:/libqfieldsync:ro
# allow local development for `qfieldcloud-sdk-python` if host directory present; requires `PYTHONPATH=/qfieldcloud-sdk-python:${PYTHONPATH}`
- ./docker-qgis/qfieldcloud-sdk-python:/qfieldcloud-sdk-python:ro

geodb:
image: postgis/postgis:12-3.0
Expand Down
1 change: 1 addition & 0 deletions docker-qgis/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ ENV LANG=C.UTF-8
ENV XDG_RUNTIME_DIR=/root
# allow local development for `libqfieldsync`, requires `/libqfieldsync` to be a mounted host directory
ENV PYTHONPATH=/libqfieldsync:${PYTHONPATH}
ENV PYTHONPATH=/qfieldcloud-sdk-python:${PYTHONPATH}

# upgrade `pip`. If not upgraded, installing from GitHub repo (needed for `libqfieldsync`) will result in UNKNOWN package.
RUN pip3 install --break-system-packages --upgrade pip
Expand Down

0 comments on commit fbd23ea

Please sign in to comment.