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

Input and display children #203

Merged
merged 3 commits into from
Jul 30, 2024
Merged

Input and display children #203

merged 3 commits into from
Jul 30, 2024

Conversation

chennisden
Copy link
Contributor

Write some api routes such and do some frontend work so that

  1. you may now upload children to listings
    image

  2. each child of a listing is displayed
    image

@chennisden
Copy link
Contributor Author

By the way, this is stacked on top of #202, just because I dont want to deal with potential merge conflict

@@ -109,7 +113,7 @@ async def upload_mjcf(
) -> Artifact:
artifact = Artifact.create(
user_id=user_id,
artifact_type="urdf",
artifact_type="mjcf",
Copy link
Member

Choose a reason for hiding this comment

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

good catch

@@ -35,6 +35,21 @@ async def list_listings(
return await crud.get_listings(page, search_query=search_query)


@listings_router.get("/batch")
async def batch(
Copy link
Member

Choose a reason for hiding this comment

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

nit: for function names, prefer doing something like <verb>_<something>, e.g., get_batch

Comment on lines 25 to 40
@urdf_router.post("/upload")
async def upload_urdf(
user: Annotated[User, Depends(get_session_user_with_write_permission)],
crud: Annotated[Crud, Depends(Crud.get)],
file: UploadFile,
) -> UserInfoResponse:
if file.content_type != "application/gzip":
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Only tar.gz files containing a URDF are supported",
)
artifact = await crud.upload_urdf(
file=file.file,
user_id=user.id,
)
return UserInfoResponse(urdf_id=artifact.id)
Copy link
Member

Choose a reason for hiding this comment

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

question - it seems like this lets us upload multiple urdfs per listing, but then the listing endpoint only returns a single urdf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now only returns the latest urdf

Comment on lines 64 to 70
if len(urdfs) == 0:
return None
if len(urdfs) > 1:
raise InternalError(
f"""More than one URDF found for listing {listing_id}.
This is due to incorrect data in the database, likely caused by a bug."""
)
Copy link
Member

Choose a reason for hiding this comment

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

in the upload flow, it seems like there is nothing stopping us from uploading multiple urdfs per listing - we should reflect this in the crud side of things

@chennisden chennisden changed the base branch from master to urdf July 30, 2024 17:46
… listing page (#211)

* Add route to fetch artifacts in bulk and return only images

* In Listings, fetch images from artifact_ids

This fixes captions being just "caption" (which was a placeholder
waiting for this commit) and also fixes trying to render URDF tar
gunzips.

* Add 'name' field to Artifacts, which stores filename

This is so people have a good identifier for URDFs, etc.

* Take in a listing for upload_urdf

- Check whether user actually owns that listing
- Update listing artifact_ids

* rename batch to get_batch

* Change route that gets unique urdf to route that gets latest
@chennisden chennisden merged commit 5411aec into urdf Jul 30, 2024
@chennisden chennisden deleted the children branch July 30, 2024 19:57
codekansas pushed a commit that referenced this pull request Jul 30, 2024
* Add functionality to set children

* Display children

* Fetch images from artifact ids and render their captions correctly in listing page (#211)

* Add route to fetch artifacts in bulk and return only images

* In Listings, fetch images from artifact_ids

This fixes captions being just "caption" (which was a placeholder
waiting for this commit) and also fixes trying to render URDF tar
gunzips.

* Add 'name' field to Artifacts, which stores filename

This is so people have a good identifier for URDFs, etc.

* Take in a listing for upload_urdf

- Check whether user actually owns that listing
- Update listing artifact_ids

* rename batch to get_batch

* Change route that gets unique urdf to route that gets latest
codekansas added a commit that referenced this pull request Jul 31, 2024
* Add upload URDF functionality

We now upload URDFs as .tar.gz files.

The URDF loader has not been implemented yet. The plan is to untar the
URDF on the client. See something like

	https://github.com/InvokIT/js-untar

* Functionality to fetch urdf

* fix mjcf upload type

* upload urdf to s3 with get_urdf_name as filename

* merge image and urdf base urls into artifact base url

* fix urdf content-type: xml => gunzip

* Input and display children (#203)

* Add functionality to set children

* Display children

* Fetch images from artifact ids and render their captions correctly in listing page (#211)

* Add route to fetch artifacts in bulk and return only images

* In Listings, fetch images from artifact_ids

This fixes captions being just "caption" (which was a placeholder
waiting for this commit) and also fixes trying to render URDF tar
gunzips.

* Add 'name' field to Artifacts, which stores filename

This is so people have a good identifier for URDFs, etc.

* Take in a listing for upload_urdf

- Check whether user actually owns that listing
- Update listing artifact_ids

* rename batch to get_batch

* Change route that gets unique urdf to route that gets latest

* quick fix

* periodic commit

* no more errors

* no more errors

* some listing details

* use react links instead of href

* fix lint

* ignore gen files

* instructions in contributing.md file

* almost there

* fix tests

* add api

* fix another test

---------

Co-authored-by: Benjamin Bolte <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants