Skip to content

Commit

Permalink
Rename enable_hidden_attributes to add_hidden_timestamp
Browse files Browse the repository at this point in the history
sed -i 's/enable_hidden_attributes/add_hidden_timestamp/g' ./**/*.py
  • Loading branch information
ethho committed Sep 22, 2024
1 parent 2b3f8d3 commit b7e99bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion datajoint/declare.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def declare(full_table_name, definition, context):
external_stores,
) = prepare_declare(definition, context)

if config.get("enable_hidden_attributes", False):
if config.get("add_hidden_timestamp", False):
metadata_attr_sql = [
"`_{full_table_name}_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP"
]
Expand Down
2 changes: 1 addition & 1 deletion datajoint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"display.show_tuple_count": True,
"database.use_tls": None,
"enable_python_native_blobs": True, # python-native/dj0 encoding support
"enable_hidden_attributes": False,
"add_hidden_timestamp": False,
"filepath_checksum_size_limit": None, # file size limit for when to disable checksums
}
)
Expand Down
40 changes: 15 additions & 25 deletions tests/test_declare.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@


@pytest.fixture(scope="function")
def enable_hidden_attributes():
orig_config_val = config.get("enable_hidden_attributes")
config["enable_hidden_attributes"] = True
def enable_add_hidden_timestamp():
orig_config_val = config.get("add_hidden_timestamp")
config["add_hidden_timestamp"] = True
yield
if orig_config_val is not None:
config["enable_hidden_attributes"] = orig_config_val
config["add_hidden_timestamp"] = orig_config_val


@pytest.fixture(scope="function")
def disable_hidden_attributes():
orig_config_val = config.get("enable_hidden_attributes")
config["enable_hidden_attributes"] = False
def disable_add_hidden_timestamp():
orig_config_val = config.get("add_hidden_timestamp")
config["add_hidden_timestamp"] = False
yield
if orig_config_val is not None:
config["enable_hidden_attributes"] = orig_config_val
config["add_hidden_timestamp"] = orig_config_val


def test_schema_decorator(schema_any):
Expand Down Expand Up @@ -392,17 +392,15 @@ class Table_With_Underscores(dj.Manual):
schema_any(Table_With_Underscores)


def test_hidden_attributes_default_value():
config_val = config.get("enable_hidden_attributes")
def test_add_hidden_timestamp_default_value():
config_val = config.get("add_hidden_timestamp")
assert (
config_val is not None and not config_val
), "Default value for enable_hidden_attributes is not False"
), "Default value for add_hidden_timestamp is not False"


def test_hidden_attributes_enabled(enable_hidden_attributes, schema_any):
orig_config_val = config.get("enable_hidden_attributes")
config["enable_hidden_attributes"] = True

def test_add_hidden_timestamp_enabled(enable_add_hidden_timestamp, schema_any):
assert config["add_hidden_timestamp"], "add_hidden_timestamp is not enabled"
msg = f"{Experiment().heading._attributes=}"
assert any(
a.name.endswith("_timestamp") for a in Experiment().heading._attributes.values()
Expand All @@ -413,14 +411,9 @@ def test_hidden_attributes_enabled(enable_hidden_attributes, schema_any):
assert any(a.is_hidden for a in Experiment().heading._attributes.values()), msg
assert not any(a.is_hidden for a in Experiment().heading.attributes.values()), msg

if orig_config_val is not None:
config["enable_hidden_attributes"] = orig_config_val


def test_hidden_attributes_disabled(disable_hidden_attributes, schema_any):
orig_config_val = config.get("enable_hidden_attributes")
config["enable_hidden_attributes"] = False

def test_add_hidden_timestamp_disabled(disable_add_hidden_timestamp, schema_any):
assert not config["add_hidden_timestamp"], "expected add_hidden_timestamp to be False"
msg = f"{Experiment().heading._attributes=}"
assert not any(
a.name.endswith("_timestamp") for a in Experiment().heading._attributes.values()
Expand All @@ -430,6 +423,3 @@ def test_hidden_attributes_disabled(disable_hidden_attributes, schema_any):
), msg
assert not any(a.is_hidden for a in Experiment().heading._attributes.values()), msg
assert not any(a.is_hidden for a in Experiment().heading.attributes.values()), msg

if orig_config_val is not None:
config["enable_hidden_attributes"] = orig_config_val

0 comments on commit b7e99bc

Please sign in to comment.