Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Environment variables lose to datajoint.json for settings missing from ENV_VAR_MAPPING

Đang mở
#1,585 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@dimitri-yatsenko đang làm issue này rồi.

Từ ngày 13/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

settings.py documents environment variables as taking precedence over datajoint.json. _update_from_flat_dict enforces that only for keys listed in ENV_VAR_MAPPING. For any other key, loading datajoint.json overwrites the value read from the environment.

ENV_VAR_MAPPING lists database.* (except use_tls), loglevel, and two display.* keys. For the following settings, the file wins over the environment:

  • jobs.* (DJ_JOBS_*)
  • provenance.* (DJ_PROVENANCE_*)
  • database.use_tls (DJ_USE_TLS)
  • the top-level safemode, query_cache, and download_path (DJ_SAFEMODE, DJ_QUERY_CACHE, DJ_DOWNLOAD_PATH)

Reproduce

On 2.3.4 (settings.py on master is unchanged):

{"safemode": true, "database.use_tls": true, "jobs.keep_completed": false,
 "provenance.capture": false, "database.host": "file-host"}
$ DJ_SAFEMODE=false DJ_USE_TLS=false DJ_JOBS_KEEP_COMPLETED=true \
  DJ_PROVENANCE_CAPTURE=true DJ_HOST=env-host python -c "import datajoint as dj; ..."
database.host        env-host   # mapped: env wins
safemode             True       # file wins
database.use_tls     True       # file wins
jobs.keep_completed  False      # file wins
provenance.capture   False      # file wins

Effect

A deployment cannot use the environment to override a key that the project's datajoint.json sets. For example, one worker cannot turn off safemode or provenance capture for a pipeline whose file sets it.

Fix

Derive the check from the settings models. Remove the hand-kept mapping. A field's environment variable is its validation_alias, or else its group's env_prefix plus the field name. This way a new setting cannot fall outside the precedence rule. Add a parametrized test over every field that reads an environment variable: set the environment variable and the file key to different values, and assert that the environment value wins.

Ngôn ngữ chính
Python
Star
197
Fork
99
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của datajoint/datajoint-python

Tất cả issue của datajoint/datajoint-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.