voxel51/fiftyone

[BUG] Datasets cannot have 'pk' fields

Open

#2,192 创建于 2022年10月24日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Python (400 fork)batch import
bugcoregood first issue

仓库指标

Star
 (4,021 star)
PR 合并指标
 (平均合并 5天 22小时) (30 天内合并 188 个 PR)

描述

Datasets cannot currently have a pk field:

import fiftyone as fo

sample = fo.Sample(filepath="image.jpg", pk=123)

dataset = fo.Dataset()
dataset.add_sample(sample)

dataset.set_values("foo", ["bar"])
# TypeError: id must be an instance of (bytes, str, ObjectId), not <class 'int'>

I believe pk should be a reserved keyword, IE these should be updated to raise errors:

sample = fo.Sample(filepath="image.jpg")
sample["pk"]  # ValueError: 'pk' is a reserved keyword

sample = fo.Sample(filepath="image.jpg", pk=123)    # ValueError: 'pk' is a reserved keyword

There may be other such keywords that need similar handling, btw.

I haven't investigated the source of the error. It might be possible to instead patch things so that pk is allowable.

贡献者指南