Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new API design doc #447

Merged
merged 16 commits into from
Apr 25, 2022
Prev Previous commit
Next Next commit
Make set_metadata() modify objects in-place
  • Loading branch information
jwodder committed Jun 4, 2021
commit 6d731db36ec5bde31c5df1171fa4127c86677af0
4 changes: 2 additions & 2 deletions doc/design/python-api-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Designs for an improved Python API
* TO DO: Add an argument for controlling whether to create a directory under `target_dir` with the same name as the Dandiset ID?

* Methods of the `DraftDandiset` class (a subclass of `RemoteDandiset` used only for mutable draft versions):
* `set_metadata(metadata: DandisetMeta) -> DraftDandiset` — returns the new, modified object
* `set_metadata(metadata: DandisetMeta) -> None` — modifies instance in-place
* Methods for uploading an individual asset:
* `upload_file(filepath: Union[str, Path], metadata: BareAssetMeta, show_progress=True, existing="refesh", validation="require") -> RemoteAsset`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metadata should not be provided but extracted as part of the *upload_file*

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of this method is to support generic file uploads where the user crafts the metadata themselves. If we only want to support upload of files that can be represented with LocalAsset instances, we can get rid of it.

* `iter_upload_file(filepath: Union[str, Path], metadata: BareAssetMeta, existing="refesh", validation="require") -> Iterator[UploadProgressDict]`
Expand Down Expand Up @@ -105,7 +105,7 @@ Designs for an improved Python API
* `version_id: str`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like dandiset version? also would not bother... may be if we are to establish relationship to a specific dandiset, could be via .dandiset: RemoteDandiset

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Dandiset version. Same response as above.

* `get_metadata() -> RemoteAssetMeta`
* `get_raw_metadata() -> dict` — useful when the metadata is invalid
* `set_metadata(metadata: BareAssetMeta) -> RemoteAsset` — returns the new, modified object
* `set_metadata(metadata: BareAssetMeta) -> None` — Assuming assets keep their identifier on metadata change, this modifies the instance in-place; otherwise, it should return the new, modified instance
* `delete() -> None`
* `download(filepath: str, show_progress=True, chunk_size=...) -> ???`
* `iter_download(filepath: str, chunk_size=...) -> Iterator[DownloadProgressDict]`
Expand Down