Skip to content

Commit 7a8ce36

Browse files
committed
refactor: simplify volume loading and DEBUG variables
1 parent f14fa74 commit 7a8ce36

File tree

5 files changed

+21
-34
lines changed

5 files changed

+21
-34
lines changed

.env.example

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,8 @@ DEBUG_WORKER_WRAPPER_DEBUGPY_PORT=5679
384384
# DEFAULT: ""
385385
DEBUG_QGIS_DEBUGPY_PORT=""
386386

387-
# Host path to `libqfieldsync` which will be mounted by the `worker_wrapper` into the `worker` containers to facilitate development and debugging of `libqfieldsync`.
388-
# If empty value or invalid value, the pip installed version defined in `requirements_libqfieldsync.txt` will be used.
389-
# The provided path must be the root of the https://github.com/opengisch/libqfieldsync repository.
387+
# Host path which will be mounted by the `worker_wrapper` into the `worker` containers to facilitate development and debugging pythons files.
388+
# Will mount `qfc_worker`, `entrypoint.py`, and if existent - `qfieldcloud-sdk` and `libqfieldsync`.
389+
# If empty value or invalid value, the copied by docker or pip installed versions will be used.
390390
# DEFAULT: ""
391-
DEBUG_QGIS_LIBQFIELDSYNC_HOST_PATH=""
392-
393-
# Host path to `qfieldcloud-sdk-python` which will be mounted by the `worker_wrapper` into the `worker` containers to facilitate development and debugging of `qfieldcloud-sdk`.
394-
# If empty value or invalid value, the pip installed version defined in `requirements.txt` will be used.
395-
# The provided path must be the root of the https://github.com/opengisch/qfieldcloud-sdk-python repository.
396-
# DEFAULT: ""
397-
DEBUG_QGIS_QFIELDCLOUD_SDK_HOST_PATH=""
391+
DEBUG_QGIS_WORKER_HOST_PATH=""

docker-app/qfieldcloud/settings.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -723,15 +723,8 @@ def before_send(event, hint):
723723
# URL the qgis worker will use to access the running API endpoint on the app service
724724
QFIELDCLOUD_WORKER_QFIELDCLOUD_URL = os.environ["QFIELDCLOUD_WORKER_QFIELDCLOUD_URL"]
725725

726-
# Absolute path on the docker host where `libqfieldsync` is mounted from for development
727-
DEBUG_QGIS_LIBQFIELDSYNC_HOST_PATH = os.environ.get(
728-
"DEBUG_QGIS_LIBQFIELDSYNC_HOST_PATH"
729-
)
730-
731-
# Absolute path on the docker host where `qfieldcloud-sdk-python` is mounted from for development
732-
DEBUG_QGIS_QFIELDCLOUD_SDK_HOST_PATH = os.environ.get(
733-
"DEBUG_QGIS_QFIELDCLOUD_SDK_HOST_PATH"
734-
)
726+
# Host path which will be mounted by the `worker_wrapper` into the `worker` containers to facilitate development and debugging pythons files.
727+
DEBUG_QGIS_WORKER_HOST_PATH = os.environ.get("DEBUG_QGIS_WORKER_HOST_PATH")
735728

736729
# Port to be used by `debugpy` to connect to the QGIS process inside the `qgis` container
737730
DEBUG_QGIS_DEBUGPY_PORT = os.environ.get("DEBUG_QGIS_DEBUGPY_PORT")

docker-app/worker_wrapper/wrapper.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ def run(self):
213213
self.before_docker_run()
214214

215215
command = self.get_command()
216-
volumes = []
217-
volumes.append(f"{str(self.shared_tempdir)}:/io/:rw")
218216

219217
exit_code, output = self._run_docker(command)
220218

@@ -343,16 +341,19 @@ def _run_docker(self, command: list[str]) -> tuple[int, bytes]:
343341
}
344342
)
345343

346-
# used for local development of QFieldCloud
347-
if settings.DEBUG_QGIS_LIBQFIELDSYNC_HOST_PATH:
348-
volumes.append(
349-
f"{settings.DEBUG_QGIS_LIBQFIELDSYNC_HOST_PATH}:/libqfieldsync:ro"
350-
)
351-
352-
# used for local development of QFieldCloud
353-
if settings.DEBUG_QGIS_QFIELDCLOUD_SDK_HOST_PATH:
354-
volumes.append(
355-
f"{settings.DEBUG_QGIS_QFIELDCLOUD_SDK_HOST_PATH}:/qfieldcloud-sdk-python:ro"
344+
if settings.DEBUG_QGIS_WORKER_HOST_PATH:
345+
debug_host_path = Path(settings.DEBUG_QGIS_WORKER_HOST_PATH)
346+
347+
volumes.extend(
348+
[
349+
# allow local development for `docker-qgis`
350+
f"{debug_host_path.joinpath('qfc_worker')}:/usr/src/app/qfc_worker:ro",
351+
f"{debug_host_path.joinpath('entrypoint.py')}:/usr/src/app/entrypoint.py:ro",
352+
# allow local development for `libqfieldsync` if host directory present; requires `PYTHONPATH=/libqfieldsync:${PYTHONPATH}`
353+
f"{debug_host_path.joinpath('libqfieldsync')}:/libqfieldsync.py:ro",
354+
# allow local development for `qfieldcloud-sdk-python` if host directory present; requires `PYTHONPATH=/qfieldcloud-sdk-python:${PYTHONPATH}`"
355+
f"{debug_host_path.joinpath('qfieldcloud-sdk-python')}:/qfieldcloud-sdk-python.py:ro",
356+
]
356357
)
357358

358359
logger.info(f"Execute: {' '.join(command)}")

docker-compose.override.local.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ services:
3535
ports:
3636
- ${DEBUG_WORKER_WRAPPER_DEBUGPY_PORT:-5679}:5679
3737
environment:
38-
DEBUG_QGIS_LIBQFIELDSYNC_HOST_PATH: ${DEBUG_QGIS_LIBQFIELDSYNC_HOST_PATH}
39-
DEBUG_QGIS_QFIELDCLOUD_SDK_HOST_PATH: ${DEBUG_QGIS_QFIELDCLOUD_SDK_HOST_PATH}
4038
DEBUG_QGIS_DEBUGPY_PORT: ${DEBUG_QGIS_DEBUGPY_PORT}
39+
DEBUG_QGIS_WORKER_HOST_PATH: ${DEBUG_QGIS_WORKER_HOST_PATH:-}
4140
volumes:
4241
# mount the source for live reload
4342
- ./docker-app/qfieldcloud:/usr/src/app/qfieldcloud

scripts/check_envvars.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash -e
22

3-
python3 scripts/check_envvars.py .env.example --docker-compose-dir . --ignored-varnames DEBUG_APP_DEBUGPY_PORT DEBUG_WORKER_WRAPPER_DEBUGPY_PORT DEBUG_QGIS_DEBUGPY_PORT
3+
python3 scripts/check_envvars.py .env.example --docker-compose-dir . --ignored-varnames DEBUG_APP_DEBUGPY_PORT DEBUG_WORKER_WRAPPER_DEBUGPY_PORT DEBUG_QGIS_DEBUGPY_PORT DEBUG_QGIS_WORKER_HOST_PATH

0 commit comments

Comments
 (0)