Skip to content

Improve UX/documentation for new Python API #731

Open

Description

@yarikoptic

inspired by https://github.com/dandi/dandi-cli/pull/676/files#r673408547 and the fact that majority of seemingly public classes aren't intended to be used by public directly etc. ATM of that PR import of dandi.dandiapi provides over 40 names, and it is hard-to-impossible to figure out what to use without RTFM (which is yet to be composed anyways).

I think we should

  • provide main modules docstring describing their purpose and what functionality is there to be actually used by users
  • may be define __all__ with those which should be imported if users do import *
  • classes such as RemoteDandiset etc should get sensible __repr__ so they convey what the are instead of default Python's class + IDs for those objects. Do not need to be a real repr and thus could even be within <> or some other decoration? done for __str__ in Give API resource classes __str__ methods #753
even such a simple one is already handy
+    def __repr__(self):
+        return f"<{self.__class__.__name__} {self.identifier}>" # + all non-None..
$> python -c 'from dandi.dandiapi import *; cl = DandiAPIClient(); print(list(cl.get_dandisets()))'     
[<RemoteDandiset 000003>, <RemoteDandiset 000004>, <RemoteDandiset 000005>,...

Activity

  1. yarikoptic commented on Nov 6, 2026

    @yarikoptic
    MemberAuthor

    @yarikoptic-gitmate pick this up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions