datachain icon indicating copy to clipboard operation
datachain copied to clipboard

Refactor public API to be nested under objects

Open ilongin opened this issue 5 months ago • 3 comments

Currently we have dc methods all under "root" object, e.g dc.read_dataset(), dc.read_storage(), dc.read_pandas()

There is an idea to group actions under objects so we will have:

dc.read_dataset() -> dc.datasets.read()
dc.delete_dataset() -> dc.datasets.delete()
dc.datasets() -> dc.datasets.ls()
dc.create_project() -> dc.projects.create()
dc.read_storage() -> dc.storages.read()
dc.read_json() -> dc.json.read()
dc.read_pandas() -> dc.pandas.read()

Does this make sense or some should be grouped and others no? To me these last two examples with json and pandas doesn't looks so good so maybe we should group only some of those? On the other hand we should have consistent API. WDYT?

ilongin avatar Jul 02 '25 22:07 ilongin

dc.read_dataset() -> dc.datasets.read()

Yes, but top level dc.read_dataset() is needed.

dc.delete_dataset() -> dc.datasets.delete() dc.datasets() -> dc.datasets.ls()

Yes. Why dc.datasets.? It should be renames to dc.dataset

dc.create_project() -> dc.projects.create()

We should stop using project. Only namespaces.

dc.read_storage() -> dc.storages.read()

Same as read_dataset(). It's ok to have dc.storages.read() but top level is still preferred way for users. btw.. the current read_storage() inside storage is overloaded name.

dc.read_json() -> dc.json.read() dc.read_pandas() -> dc.pandas.read()

No. Agree with your comment.

dmpetrov avatar Jul 02 '25 22:07 dmpetrov

dc.read_dataset() -> dc.datasets.read()

Yes, but top level dc.read_dataset() is needed.

Yea, we would def need to leave current top level methods, at least for backward compatibility but not sure if we should deprecate them or leave forever. Not a big fan of having 2 aliases for one API.

Yes. Why dc.datasets.? It should be renames to dc.dataset

Isn't usually plural used in these kind of things? Anyway I don't have strong opinion but we should be consistent with singular / plural with all objects

ilongin avatar Jul 02 '25 23:07 ilongin

we should be consistent with singular / plural with all objects

yes, singular is preferred

dmpetrov avatar Jul 02 '25 23:07 dmpetrov