Skip to content

Loosen Feature type naming constraints #3460

@Zethson

Description

@Zethson

Add a description

lightning_type = ln.Feature(name="__Lamindb_lightning__", is_type=True).save()

fails with

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[12], line 1
----> 1 lightning_type = ln.Feature(name="__Lamindb_lightning__", is_type=True).save()

File ~/code/lamindb/lamindb/models/feature.py:1072, in __init__(self, *args, **kwargs)
   1060 """Rank of feature.
   1061 
   1062 Number of indices of the array: 0 for scalar, 1 for vector, 2 for matrix.
   (...)   1065 the dimension of the feature space.
   1066 """
   1067 array_size: int = models.IntegerField(default=0, db_index=True)
   1068 """Number of elements of the feature.
   1069 
   1070 Total number of elements (product of shape components) of the array.
   1071 
-> 1072 - A number or string (a scalar): 1 or `None`
   1073 - A 50-dimensional embedding: 50
   1074 - A 25 x 25 image: 625
   1075 """
   1076 array_shape: list[int] | None = JSONField(default=None, db_default=None, null=True)
   1077 """Shape of the feature.
   1078 
   1079 - A number or string (a scalar): [1] or `None`
   (...)   1083 Is stored as a list rather than a tuple because it's serialized as JSON.
   1084 """

File ~/code/lamindb/lamindb/models/sqlrecord.py:954, in __init__(self, *args, **kwargs)
    950 if "space_id" in kwargs:
    951     # space_id takes precedence over space
    952     # https://claude.ai/share/f045e5dc-0143-4bc5-b8a4-38309229f75e
    953     if kwargs["space_id"] == 1:  # ignore default space
--> 954         kwargs.pop("space_id")
    955         kwargs["space"] = current_space
    956 elif "space" in kwargs:

File ~/code/lamindb/lamindb/models/sqlrecord.py:374, in validate_fields(record, kwargs)
    362 from lamindb.models import (
    363     Artifact,
    364     Collection,
   (...)    369     ULabel,
    370 )
    372 # validate required fields
    373 # a "required field" is a Django field that has `null=False, default=None`
--> 374 required_fields = {
    375     k.name for k in record._meta.fields if not k.null and k.default is None
    376 }
    377 required_fields_not_passed = {k: None for k in required_fields if k not in kwargs}
    378 kwargs.update(required_fields_not_passed)

File ~/code/lamindb/lamindb/models/sqlrecord.py:240, in is_approx_pascal_case(s)
    238     fields_part = error_msg.split("Key (")[1].split(")=")[0]
    239     fields = [f.strip() for f in fields_part.split(",")]
--> 240     return fields
    242 # Fallback if DETAIL line not available
    243 return [field_string]

ValueError: '__Lamindb_lightning__' should start with a capital letter given you're defining a type

we should strip every non-letter character when checking this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions