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

Upload reviewable method #165

Merged
merged 2 commits into from
Aug 2, 2024
Merged

Conversation

iLLiCiTiT
Copy link
Member

@iLLiCiTiT iLLiCiTiT commented Jul 19, 2024

Description

Implemented helper method to upload reviewable to server.

Additional information

It was necessary to implement helper function to determine mime data of reviewable file to be able to implement the function. Other way around would to be expect filled type, which can easily cause huge amount of code duplications when used from multiple places.

Testing notes

You should be able to upload video file to version as reviewable. Choose project, find a version and try to detect it's id and call

# Expecting global api connection is created
import ayon_api

project_name = "..."
version_id = "..."
filepath = "..."
ayon_api.upload_reviewable(project_name, version_id, filepath)

Reviewable should be visible in AYON web server.

@iLLiCiTiT iLLiCiTiT requested a review from antirotor July 19, 2024 17:16
@iLLiCiTiT iLLiCiTiT requested a review from kalisp July 19, 2024 17:17
@BigRoy BigRoy added the type: enhancement New feature or request label Aug 2, 2024
Copy link

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

Very nice - this works!

I do wonder, is the return type hint correct? I expected response.data to be a valid property.

But doing this:

print(response)
print(response.text)
print(response.data)

Gave me:

<Response [200]>
{"fileId":"27bf483250b711efa33c0242ac120004","activityId":"282c921650b711efa33c0242ac120004","filename":"McD_pitch_winter24_styleframe_underwater_v001.jpg","label":null,"mimetype":"image/jpeg","availability":"ready","mediaInfo":{"probeVersion":1,"majorBrand":null,"videoTrackIndex":0,"width":1080,"height":1920,"pixelFormat":"yuvj420p","frameRate":25.0,"duration":0.0,"codec":"mjpeg","iframeOnly":true},"createdFrom":null,"processing":null,"createdAt":"2024-08-02T10:08:25.617905","updatedAt":"2024-08-02T10:08:25.617912","author":{"name":"admin","fullName":"Roy Nieterau"}}
# Error: 'Response' object has no attribute 'data'
# # Traceback (most recent call last):
# #   File "<maya console>", line 15, in <module>
# # AttributeError: 'Response' object has no attribute 'data'

So it returns Response instead of RestApiResponse

Bonus points for adding RestApiResponse as import for type hints in _api just for type hints to propagate.

@iLLiCiTiT iLLiCiTiT merged commit c7c6f8a into develop Aug 2, 2024
@iLLiCiTiT iLLiCiTiT deleted the enhancement/add-upload-reviewable branch August 2, 2024 12:29
@iLLiCiTiT
Copy link
Member Author

iLLiCiTiT commented Aug 2, 2024

I do wonder, is the return type hint correct? I expected response.data to be a valid property.

I think you've uncovered something. Will create issue, and PR when I find some time.

EDITED:
Issue #168

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants