database_prefix deprecation warning says "will be removed in DataJoint 2.3", but the setting is still present in 2.3.x

未關閉
#1,675 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 6 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
文件
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
mysql, postgresql, python

研究方向

Read how-to/deploy-production.md and reference/configuration.md, then compare their database_prefix guidance with the warning emitted by Schema.activate() and the setting in DatabaseSettings. Decide which deprecation schedule the maintainers want before changing the warning or docs; the issue presents two alternatives. Done when the code and documentation agree and production guidance no longer presents the deprecated setting as a normal recommendation.

由索引模型根據 Issue 內容生成。

描述

bug

Summary

database.database_prefix has been deprecated since 2.2.1. When it is set, Schema.activate() warns:

DeprecationWarning: database_prefix is deprecated and will be removed in DataJoint 2.3. Use database.name to select a PostgreSQL database instead.

The 2.3 releases have shipped (up to 2.3.5), and the setting is still there. dj.config.database.database_prefix and the DJ_DATABASE_PREFIX environment variable are both still accepted, and the warning still names 2.3 as the removal release. No release note gives a different schedule.

The warning is the only place the library reads the value. It is never applied to schema names, so dj.Schema("subject") activates subject whether or not a prefix is set. Users only get a prefix by adding it to schema names in their own code.

The documentation repeats the outdated schedule:

  • how-to/deploy-production.md, "Use Database Prefixes": a "Deprecated in 2.2.1" note says database_prefix "will be removed in 2.3". The section below it still teaches setting the prefix and building schema names from it.
  • The same page also uses it in production examples: DJ_DATABASE_PREFIX=prod_ in the environment and container examples, a verification script that reports an error when database_prefix is unset, and the development/production summary table.
  • reference/configuration.md marks the setting as deprecated without a version.

Reproduction

Against any fresh schema on DataJoint 2.3.x:

import warnings
import datajoint as dj

dj.config.database.database_prefix = "myproject_"

warnings.simplefilter("always", DeprecationWarning)
schema = dj.Schema("prefix_check")   # activates the schema and emits the warning

@schema
class Subject(dj.Manual):
    definition = """
    subject_id : int32
    ---
    subject_name : varchar(64)
    weight : float64
    """

print(dj.__version__)                       # 2.3.x
print(dj.config.database.database_prefix)   # 'myproject_'  (setting still accepted)
print(schema.database)                      # 'prefix_check' (prefix not applied)

Output (shown on a 2.3.5 development build):

DeprecationWarning: database_prefix is deprecated and will be removed in DataJoint 2.3. Use database.name to select a PostgreSQL database instead.
2.3.5...
myproject_
prefix_check

Expected behavior

The warning should name a release that has not shipped yet, or not name one at all. The documentation should give the same schedule as the code, and production guides should not recommend a deprecated setting as a normal production setting.

Options

These are two ways to fix it, and this issue does not pick one.

  1. Remove it in 2.4 on a stated schedule. On master, change the warning to "will be removed in DataJoint 2.4" so 2.3.x users get an accurate notice. On next, remove the setting: the database_prefix field in DatabaseSettings, the DJ_DATABASE_PREFIX mapping, and the check in Schema.activate(). Record the removal in the 2.4 release notes. In the docs, replace the "Use Database Prefixes" section and the production examples with the recommended alternative, keeping in mind that database.name selects a PostgreSQL database and has no direct MySQL equivalent.
  2. Correct the message and keep the setting for now. Change the warning to say the setting is deprecated and will be removed in a future release, or name a release once one is agreed. Make the docs say the same thing, and remove database_prefix from the production checklist, the example environments, and the summary table so the docs no longer recommend it.

With either option, the deprecation note in how-to/deploy-production.md and the entry in reference/configuration.md should match whatever the code says.

主要語言
Python
星號
198
分支
103
平均合併
6 天 1 小時
30 天內合併 PR
10

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

datajoint/datajoint-python 的其他 Issue

查看 datajoint/datajoint-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。