laminlabs / bionty

Registries for biological entities, coupled to public ontologies.
Apache License 2.0
11 stars 2 forks source link

register_source_in_bionty_assets uses Artifact keyword _key_is_virtual for constructor but does not pass kwarg length check #88

Closed Zethson closed 2 months ago

Zethson commented 2 months ago
artifact = ln.Artifact(
            filepath, key=filepath.name, _key_is_virtual=False
        ).save()

In register_source_in_bionty_assets

leads to

File ~/PycharmProjects/lamindb/lamindb/_artifact.py:538, in __init__(artifact, *args, **kwargs)
    536 accessor = _check_accessor_artifact(data=data, accessor=accessor)
    537 if not len(kwargs) == 0:
--> 538     raise ValueError(
    539         "Only data, key, run, description, version, is_new_version_of, visibility"
    540         f" can be passed, you passed: {kwargs}"
    541     )
ValueError: Only data, key, run, description, version, is_new_version_of, visibility can be passed, you passed: {'_key_is_virtual': False}

which can be fixed by simply popping the kwarg in the Artifact constructor (in lamindb) like:

    key_is_virtual = kwargs.pop("_key_is_virtual") if "_key_is_virtual" in kwargs else True
    if not len(kwargs) == 0:
        raise ValueError(
            "Only data, key, run, description, version, is_new_version_of, visibility"
            f" can be passed, you passed: {kwargs}"
        )

We can pop it and use it in get_artifact_kwargs_from_data?