magic_hour 0.9.5__py3-none-any.whl → 0.44.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- magic_hour/README.md +34 -0
- magic_hour/__init__.py +1 -1
- magic_hour/client.py +8 -17
- magic_hour/environment.py +13 -1
- magic_hour/helpers/__init__.py +4 -0
- magic_hour/helpers/download.py +77 -0
- magic_hour/helpers/logger.py +8 -0
- magic_hour/resources/v1/README.md +32 -0
- magic_hour/resources/v1/ai_clothes_changer/README.md +94 -5
- magic_hour/resources/v1/ai_clothes_changer/client.py +161 -16
- magic_hour/resources/v1/ai_face_editor/README.md +195 -0
- magic_hour/resources/v1/ai_face_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_face_editor/client.py +324 -0
- magic_hour/resources/v1/ai_gif_generator/README.md +116 -0
- magic_hour/resources/v1/ai_gif_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_gif_generator/client.py +257 -0
- magic_hour/resources/v1/ai_headshot_generator/README.md +81 -3
- magic_hour/resources/v1/ai_headshot_generator/client.py +167 -18
- magic_hour/resources/v1/ai_image_editor/README.md +125 -0
- magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_image_editor/client.py +290 -0
- magic_hour/resources/v1/ai_image_generator/README.md +99 -5
- magic_hour/resources/v1/ai_image_generator/client.py +170 -24
- magic_hour/resources/v1/ai_image_upscaler/README.md +89 -3
- magic_hour/resources/v1/ai_image_upscaler/client.py +173 -20
- magic_hour/resources/v1/ai_meme_generator/README.md +129 -0
- magic_hour/resources/v1/ai_meme_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_meme_generator/client.py +253 -0
- magic_hour/resources/v1/ai_photo_editor/README.md +119 -4
- magic_hour/resources/v1/ai_photo_editor/client.py +199 -18
- magic_hour/resources/v1/ai_qr_code_generator/README.md +84 -3
- magic_hour/resources/v1/ai_qr_code_generator/client.py +140 -18
- magic_hour/resources/v1/ai_talking_photo/README.md +137 -0
- magic_hour/resources/v1/ai_talking_photo/__init__.py +4 -0
- magic_hour/resources/v1/ai_talking_photo/client.py +326 -0
- magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
- magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
- magic_hour/resources/v1/ai_voice_generator/README.md +112 -0
- magic_hour/resources/v1/ai_voice_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_generator/client.py +241 -0
- magic_hour/resources/v1/animation/README.md +128 -6
- magic_hour/resources/v1/animation/client.py +247 -22
- magic_hour/resources/v1/audio_projects/README.md +135 -0
- magic_hour/resources/v1/audio_projects/__init__.py +12 -0
- magic_hour/resources/v1/audio_projects/client.py +310 -0
- magic_hour/resources/v1/audio_projects/client_test.py +520 -0
- magic_hour/resources/v1/auto_subtitle_generator/README.md +128 -0
- magic_hour/resources/v1/auto_subtitle_generator/__init__.py +4 -0
- magic_hour/resources/v1/auto_subtitle_generator/client.py +346 -0
- magic_hour/resources/v1/client.py +75 -1
- magic_hour/resources/v1/face_detection/README.md +157 -0
- magic_hour/resources/v1/face_detection/__init__.py +12 -0
- magic_hour/resources/v1/face_detection/client.py +380 -0
- magic_hour/resources/v1/face_swap/README.md +137 -9
- magic_hour/resources/v1/face_swap/client.py +329 -38
- magic_hour/resources/v1/face_swap_photo/README.md +118 -3
- magic_hour/resources/v1/face_swap_photo/client.py +199 -14
- magic_hour/resources/v1/files/README.md +39 -0
- magic_hour/resources/v1/files/client.py +351 -1
- magic_hour/resources/v1/files/client_test.py +414 -0
- magic_hour/resources/v1/files/upload_urls/README.md +38 -17
- magic_hour/resources/v1/files/upload_urls/client.py +38 -34
- magic_hour/resources/v1/image_background_remover/README.md +96 -5
- magic_hour/resources/v1/image_background_remover/client.py +151 -16
- magic_hour/resources/v1/image_projects/README.md +82 -10
- magic_hour/resources/v1/image_projects/__init__.py +10 -2
- magic_hour/resources/v1/image_projects/client.py +154 -16
- magic_hour/resources/v1/image_projects/client_test.py +527 -0
- magic_hour/resources/v1/image_to_video/README.md +96 -11
- magic_hour/resources/v1/image_to_video/client.py +282 -38
- magic_hour/resources/v1/lip_sync/README.md +112 -9
- magic_hour/resources/v1/lip_sync/client.py +288 -34
- magic_hour/resources/v1/photo_colorizer/README.md +107 -0
- magic_hour/resources/v1/photo_colorizer/__init__.py +4 -0
- magic_hour/resources/v1/photo_colorizer/client.py +248 -0
- magic_hour/resources/v1/text_to_video/README.md +96 -7
- magic_hour/resources/v1/text_to_video/client.py +204 -18
- magic_hour/resources/v1/video_projects/README.md +81 -9
- magic_hour/resources/v1/video_projects/__init__.py +10 -2
- magic_hour/resources/v1/video_projects/client.py +151 -14
- magic_hour/resources/v1/video_projects/client_test.py +527 -0
- magic_hour/resources/v1/video_to_video/README.md +119 -15
- magic_hour/resources/v1/video_to_video/client.py +299 -46
- magic_hour/types/models/__init__.py +92 -56
- magic_hour/types/models/v1_ai_clothes_changer_create_response.py +33 -0
- magic_hour/types/models/v1_ai_face_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_gif_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_headshot_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_upscaler_create_response.py +33 -0
- magic_hour/types/models/v1_ai_meme_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_photo_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_qr_code_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_talking_photo_create_response.py +35 -0
- magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
- magic_hour/types/models/v1_ai_voice_generator_create_response.py +27 -0
- magic_hour/types/models/v1_animation_create_response.py +35 -0
- magic_hour/types/models/v1_audio_projects_get_response.py +72 -0
- magic_hour/types/models/v1_audio_projects_get_response_downloads_item.py +19 -0
- magic_hour/types/models/{get_v1_image_projects_id_response_error.py → v1_audio_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_auto_subtitle_generator_create_response.py +35 -0
- magic_hour/types/models/v1_face_detection_create_response.py +25 -0
- magic_hour/types/models/v1_face_detection_get_response.py +45 -0
- magic_hour/types/models/v1_face_detection_get_response_faces_item.py +25 -0
- magic_hour/types/models/v1_face_swap_create_response.py +35 -0
- magic_hour/types/models/v1_face_swap_photo_create_response.py +33 -0
- magic_hour/types/models/v1_files_upload_urls_create_response.py +24 -0
- magic_hour/types/models/{post_v1_files_upload_urls_response_items_item.py → v1_files_upload_urls_create_response_items_item.py} +2 -2
- magic_hour/types/models/v1_image_background_remover_create_response.py +33 -0
- magic_hour/types/models/{get_v1_image_projects_id_response.py → v1_image_projects_get_response.py} +20 -18
- magic_hour/types/models/{get_v1_video_projects_id_response_downloads_item.py → v1_image_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/{get_v1_video_projects_id_response_error.py → v1_image_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_image_to_video_create_response.py +35 -0
- magic_hour/types/models/v1_lip_sync_create_response.py +35 -0
- magic_hour/types/models/v1_photo_colorizer_create_response.py +33 -0
- magic_hour/types/models/v1_text_to_video_create_response.py +35 -0
- magic_hour/types/models/{get_v1_video_projects_id_response.py → v1_video_projects_get_response.py} +26 -23
- magic_hour/types/models/{get_v1_video_projects_id_response_download.py → v1_video_projects_get_response_download.py} +1 -1
- magic_hour/types/models/{get_v1_image_projects_id_response_downloads_item.py → v1_video_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/v1_video_projects_get_response_error.py +25 -0
- magic_hour/types/models/v1_video_to_video_create_response.py +35 -0
- magic_hour/types/params/__init__.py +422 -176
- magic_hour/types/params/v1_ai_clothes_changer_create_body.py +40 -0
- magic_hour/types/params/v1_ai_clothes_changer_create_body_assets.py +58 -0
- magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body.py +52 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_style.py +137 -0
- magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_gif_generator_create_body.py +47 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body_style.py → v1_ai_gif_generator_create_body_style.py} +5 -5
- magic_hour/types/params/v1_ai_headshot_generator_create_body.py +49 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_style.py +27 -0
- magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +47 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_style.py +41 -0
- magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +28 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body.py → v1_ai_image_generator_create_body.py} +17 -11
- magic_hour/types/params/v1_ai_image_generator_create_body_style.py +127 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body.py +59 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_image_upscaler_body_style.py → v1_ai_image_upscaler_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body.py +37 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body_style.py +73 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body.py → v1_ai_photo_editor_create_body.py} +15 -15
- magic_hour/types/params/v1_ai_photo_editor_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body_style.py → v1_ai_photo_editor_create_body_style.py} +20 -4
- magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_qr_code_generator_create_body.py +45 -0
- magic_hour/types/params/{post_v1_ai_qr_code_generator_body_style.py → v1_ai_qr_code_generator_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_talking_photo_create_body.py +68 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_assets.py +46 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +44 -0
- magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
- magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body.py +40 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +440 -0
- magic_hour/types/params/{post_v1_animation_body.py → v1_animation_create_body.py} +16 -16
- magic_hour/types/params/{post_v1_animation_body_assets.py → v1_animation_create_body_assets.py} +15 -5
- magic_hour/types/params/{post_v1_animation_body_style.py → v1_animation_create_body_style.py} +13 -10
- magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body.py +78 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style.py +56 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style_custom_config.py +86 -0
- magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_detection_create_body.py +44 -0
- magic_hour/types/params/v1_face_detection_create_body_assets.py +33 -0
- magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_swap_create_body.py +92 -0
- magic_hour/types/params/v1_face_swap_create_body_assets.py +91 -0
- magic_hour/types/params/v1_face_swap_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_face_swap_photo_create_body.py +40 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets.py +76 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_files_upload_urls_create_body.py +36 -0
- magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +38 -0
- magic_hour/types/params/v1_image_background_remover_create_body.py +40 -0
- magic_hour/types/params/v1_image_background_remover_create_body_assets.py +49 -0
- magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
- magic_hour/types/params/v1_image_to_video_create_body.py +101 -0
- magic_hour/types/params/v1_image_to_video_create_body_assets.py +33 -0
- magic_hour/types/params/v1_image_to_video_create_body_style.py +53 -0
- magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_lip_sync_create_body.py +100 -0
- magic_hour/types/params/{post_v1_lip_sync_body_assets.py → v1_lip_sync_create_body_assets.py} +15 -5
- magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
- magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
- magic_hour/types/params/v1_photo_colorizer_create_body.py +40 -0
- magic_hour/types/params/v1_photo_colorizer_create_body_assets.py +33 -0
- magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_text_to_video_create_body.py +78 -0
- magic_hour/types/params/v1_text_to_video_create_body_style.py +43 -0
- magic_hour/types/params/v1_video_to_video_create_body.py +101 -0
- magic_hour/types/params/{post_v1_video_to_video_body_assets.py → v1_video_to_video_create_body_assets.py} +9 -4
- magic_hour/types/params/{post_v1_video_to_video_body_style.py → v1_video_to_video_create_body_style.py} +68 -26
- magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
- magic_hour-0.44.0.dist-info/METADATA +328 -0
- magic_hour-0.44.0.dist-info/RECORD +231 -0
- magic_hour/core/__init__.py +0 -52
- magic_hour/core/api_error.py +0 -56
- magic_hour/core/auth.py +0 -314
- magic_hour/core/base_client.py +0 -618
- magic_hour/core/binary_response.py +0 -23
- magic_hour/core/query.py +0 -106
- magic_hour/core/request.py +0 -156
- magic_hour/core/response.py +0 -293
- magic_hour/core/type_utils.py +0 -28
- magic_hour/core/utils.py +0 -55
- magic_hour/types/models/post_v1_ai_clothes_changer_response.py +0 -25
- magic_hour/types/models/post_v1_ai_headshot_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_upscaler_response.py +0 -25
- magic_hour/types/models/post_v1_ai_photo_editor_response.py +0 -25
- magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +0 -25
- magic_hour/types/models/post_v1_animation_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_photo_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_response.py +0 -25
- magic_hour/types/models/post_v1_files_upload_urls_response.py +0 -21
- magic_hour/types/models/post_v1_image_background_remover_response.py +0 -25
- magic_hour/types/models/post_v1_image_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_lip_sync_response.py +0 -25
- magic_hour/types/models/post_v1_text_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_video_to_video_response.py +0 -25
- magic_hour/types/params/post_v1_ai_clothes_changer_body.py +0 -40
- magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +0 -45
- magic_hour/types/params/post_v1_ai_headshot_generator_body.py +0 -40
- magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_image_upscaler_body.py +0 -57
- magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +0 -45
- magic_hour/types/params/post_v1_face_swap_body.py +0 -72
- magic_hour/types/params/post_v1_face_swap_body_assets.py +0 -52
- magic_hour/types/params/post_v1_face_swap_photo_body.py +0 -40
- magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +0 -36
- magic_hour/types/params/post_v1_files_upload_urls_body.py +0 -31
- magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +0 -38
- magic_hour/types/params/post_v1_image_background_remover_body.py +0 -40
- magic_hour/types/params/post_v1_image_background_remover_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body.py +0 -73
- magic_hour/types/params/post_v1_image_to_video_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body_style.py +0 -37
- magic_hour/types/params/post_v1_lip_sync_body.py +0 -80
- magic_hour/types/params/post_v1_text_to_video_body.py +0 -57
- magic_hour/types/params/post_v1_text_to_video_body_style.py +0 -28
- magic_hour/types/params/post_v1_video_to_video_body.py +0 -93
- magic_hour-0.9.5.dist-info/METADATA +0 -133
- magic_hour-0.9.5.dist-info/RECORD +0 -132
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
|
@@ -1,30 +1,109 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
import pydantic
|
|
4
|
+
import time
|
|
1
5
|
import typing
|
|
2
6
|
|
|
3
|
-
from magic_hour.
|
|
7
|
+
from magic_hour.helpers.download import download_files_async, download_files_sync
|
|
8
|
+
from magic_hour.helpers.logger import get_sdk_logger
|
|
9
|
+
from magic_hour.types import models
|
|
10
|
+
from make_api_request import (
|
|
4
11
|
AsyncBaseClient,
|
|
5
12
|
RequestOptions,
|
|
6
13
|
SyncBaseClient,
|
|
7
14
|
default_request_options,
|
|
8
15
|
)
|
|
9
|
-
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
logger = get_sdk_logger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class V1ImageProjectsGetResponseWithDownloads(models.V1ImageProjectsGetResponse):
|
|
22
|
+
downloaded_paths: typing.Optional[typing.List[str]] = pydantic.Field(
|
|
23
|
+
default=None, alias="downloaded_paths"
|
|
24
|
+
)
|
|
25
|
+
"""
|
|
26
|
+
The paths to the downloaded files.
|
|
27
|
+
|
|
28
|
+
This field is only populated if `download_outputs` is True and the image project is complete.
|
|
29
|
+
"""
|
|
10
30
|
|
|
11
31
|
|
|
12
32
|
class ImageProjectsClient:
|
|
13
33
|
def __init__(self, *, base_client: SyncBaseClient):
|
|
14
34
|
self._base_client = base_client
|
|
15
35
|
|
|
36
|
+
def check_result(
|
|
37
|
+
self,
|
|
38
|
+
id: str,
|
|
39
|
+
wait_for_completion: bool,
|
|
40
|
+
download_outputs: bool,
|
|
41
|
+
download_directory: typing.Optional[str] = None,
|
|
42
|
+
) -> V1ImageProjectsGetResponseWithDownloads:
|
|
43
|
+
"""
|
|
44
|
+
Check the result of an image project with optional waiting and downloading.
|
|
45
|
+
|
|
46
|
+
This method retrieves the status of an image project and optionally waits for completion
|
|
47
|
+
and downloads the output files.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
id: Unique ID of the image project
|
|
51
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
52
|
+
download_outputs: Whether to download the outputs
|
|
53
|
+
download_directory: The directory to download the outputs to. If not provided,
|
|
54
|
+
the outputs will be downloaded to the current working directory
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
V1ImageProjectsGetResponseWithDownloads: The image project response with optional
|
|
58
|
+
downloaded file paths included
|
|
59
|
+
"""
|
|
60
|
+
api_response = self.get(id=id)
|
|
61
|
+
if not wait_for_completion:
|
|
62
|
+
response = V1ImageProjectsGetResponseWithDownloads(
|
|
63
|
+
**api_response.model_dump()
|
|
64
|
+
)
|
|
65
|
+
return response
|
|
66
|
+
|
|
67
|
+
poll_interval = float(os.getenv("MAGIC_HOUR_POLL_INTERVAL", "0.5"))
|
|
68
|
+
|
|
69
|
+
status = api_response.status
|
|
70
|
+
|
|
71
|
+
while status not in ["complete", "error", "canceled"]:
|
|
72
|
+
api_response = self.get(id=id)
|
|
73
|
+
status = api_response.status
|
|
74
|
+
time.sleep(poll_interval)
|
|
75
|
+
|
|
76
|
+
if api_response.status != "complete":
|
|
77
|
+
log = logger.error if api_response.status == "error" else logger.info
|
|
78
|
+
log(
|
|
79
|
+
f"Image project {id} has status {api_response.status}: {api_response.error}"
|
|
80
|
+
)
|
|
81
|
+
return V1ImageProjectsGetResponseWithDownloads(**api_response.model_dump())
|
|
82
|
+
|
|
83
|
+
if not download_outputs:
|
|
84
|
+
return V1ImageProjectsGetResponseWithDownloads(**api_response.model_dump())
|
|
85
|
+
|
|
86
|
+
downloaded_paths = download_files_sync(
|
|
87
|
+
downloads=api_response.downloads,
|
|
88
|
+
download_directory=download_directory,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return V1ImageProjectsGetResponseWithDownloads(
|
|
92
|
+
**api_response.model_dump(), downloaded_paths=downloaded_paths
|
|
93
|
+
)
|
|
94
|
+
|
|
16
95
|
def delete(
|
|
17
96
|
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
18
97
|
) -> None:
|
|
19
98
|
"""
|
|
20
99
|
Delete image
|
|
21
100
|
|
|
22
|
-
Permanently delete the rendered image. This action is not reversible, please be sure before deleting.
|
|
101
|
+
Permanently delete the rendered image(s). This action is not reversible, please be sure before deleting.
|
|
23
102
|
|
|
24
103
|
DELETE /v1/image-projects/{id}
|
|
25
104
|
|
|
26
105
|
Args:
|
|
27
|
-
id:
|
|
106
|
+
id: Unique ID of the image project. This value is returned by all of the POST APIs that create an image.
|
|
28
107
|
request_options: Additional options to customize the HTTP request
|
|
29
108
|
|
|
30
109
|
Returns:
|
|
@@ -36,7 +115,7 @@ class ImageProjectsClient:
|
|
|
36
115
|
|
|
37
116
|
Examples:
|
|
38
117
|
```py
|
|
39
|
-
client.v1.image_projects.delete(id="
|
|
118
|
+
client.v1.image_projects.delete(id="cuid-example")
|
|
40
119
|
```
|
|
41
120
|
"""
|
|
42
121
|
self._base_client.request(
|
|
@@ -49,7 +128,7 @@ class ImageProjectsClient:
|
|
|
49
128
|
|
|
50
129
|
def get(
|
|
51
130
|
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
52
|
-
) -> models.
|
|
131
|
+
) -> models.V1ImageProjectsGetResponse:
|
|
53
132
|
"""
|
|
54
133
|
Get image details
|
|
55
134
|
|
|
@@ -67,7 +146,7 @@ class ImageProjectsClient:
|
|
|
67
146
|
GET /v1/image-projects/{id}
|
|
68
147
|
|
|
69
148
|
Args:
|
|
70
|
-
id:
|
|
149
|
+
id: Unique ID of the image project. This value is returned by all of the POST APIs that create an image.
|
|
71
150
|
request_options: Additional options to customize the HTTP request
|
|
72
151
|
|
|
73
152
|
Returns:
|
|
@@ -79,14 +158,14 @@ class ImageProjectsClient:
|
|
|
79
158
|
|
|
80
159
|
Examples:
|
|
81
160
|
```py
|
|
82
|
-
client.v1.image_projects.get(id="
|
|
161
|
+
client.v1.image_projects.get(id="cuid-example")
|
|
83
162
|
```
|
|
84
163
|
"""
|
|
85
164
|
return self._base_client.request(
|
|
86
165
|
method="GET",
|
|
87
166
|
path=f"/v1/image-projects/{id}",
|
|
88
167
|
auth_names=["bearerAuth"],
|
|
89
|
-
cast_to=models.
|
|
168
|
+
cast_to=models.V1ImageProjectsGetResponse,
|
|
90
169
|
request_options=request_options or default_request_options(),
|
|
91
170
|
)
|
|
92
171
|
|
|
@@ -95,18 +174,77 @@ class AsyncImageProjectsClient:
|
|
|
95
174
|
def __init__(self, *, base_client: AsyncBaseClient):
|
|
96
175
|
self._base_client = base_client
|
|
97
176
|
|
|
177
|
+
async def check_result(
|
|
178
|
+
self,
|
|
179
|
+
id: str,
|
|
180
|
+
wait_for_completion: bool,
|
|
181
|
+
download_outputs: bool,
|
|
182
|
+
download_directory: typing.Optional[str] = None,
|
|
183
|
+
) -> V1ImageProjectsGetResponseWithDownloads:
|
|
184
|
+
"""
|
|
185
|
+
Check the result of an image project with optional waiting and downloading.
|
|
186
|
+
|
|
187
|
+
This method retrieves the status of an image project and optionally waits for completion
|
|
188
|
+
and downloads the output files.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
id: Unique ID of the image project
|
|
192
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
193
|
+
download_outputs: Whether to download the outputs
|
|
194
|
+
download_directory: The directory to download the outputs to. If not provided,
|
|
195
|
+
the outputs will be downloaded to the current working directory
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
V1ImageProjectsGetResponseWithDownloads: The image project response with optional
|
|
199
|
+
downloaded file paths included
|
|
200
|
+
"""
|
|
201
|
+
api_response = await self.get(id=id)
|
|
202
|
+
if not wait_for_completion:
|
|
203
|
+
response = V1ImageProjectsGetResponseWithDownloads(
|
|
204
|
+
**api_response.model_dump()
|
|
205
|
+
)
|
|
206
|
+
return response
|
|
207
|
+
|
|
208
|
+
poll_interval = float(os.getenv("MAGIC_HOUR_POLL_INTERVAL", "0.5"))
|
|
209
|
+
|
|
210
|
+
status = api_response.status
|
|
211
|
+
|
|
212
|
+
while status not in ["complete", "error", "canceled"]:
|
|
213
|
+
api_response = await self.get(id=id)
|
|
214
|
+
status = api_response.status
|
|
215
|
+
await asyncio.sleep(poll_interval)
|
|
216
|
+
|
|
217
|
+
if api_response.status != "complete":
|
|
218
|
+
log = logger.error if api_response.status == "error" else logger.info
|
|
219
|
+
log(
|
|
220
|
+
f"Image project {id} has status {api_response.status}: {api_response.error}"
|
|
221
|
+
)
|
|
222
|
+
return V1ImageProjectsGetResponseWithDownloads(**api_response.model_dump())
|
|
223
|
+
|
|
224
|
+
if not download_outputs:
|
|
225
|
+
return V1ImageProjectsGetResponseWithDownloads(**api_response.model_dump())
|
|
226
|
+
|
|
227
|
+
downloaded_paths = await download_files_async(
|
|
228
|
+
downloads=api_response.downloads,
|
|
229
|
+
download_directory=download_directory,
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
return V1ImageProjectsGetResponseWithDownloads(
|
|
233
|
+
**api_response.model_dump(), downloaded_paths=downloaded_paths
|
|
234
|
+
)
|
|
235
|
+
|
|
98
236
|
async def delete(
|
|
99
237
|
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
100
238
|
) -> None:
|
|
101
239
|
"""
|
|
102
240
|
Delete image
|
|
103
241
|
|
|
104
|
-
Permanently delete the rendered image. This action is not reversible, please be sure before deleting.
|
|
242
|
+
Permanently delete the rendered image(s). This action is not reversible, please be sure before deleting.
|
|
105
243
|
|
|
106
244
|
DELETE /v1/image-projects/{id}
|
|
107
245
|
|
|
108
246
|
Args:
|
|
109
|
-
id:
|
|
247
|
+
id: Unique ID of the image project. This value is returned by all of the POST APIs that create an image.
|
|
110
248
|
request_options: Additional options to customize the HTTP request
|
|
111
249
|
|
|
112
250
|
Returns:
|
|
@@ -118,7 +256,7 @@ class AsyncImageProjectsClient:
|
|
|
118
256
|
|
|
119
257
|
Examples:
|
|
120
258
|
```py
|
|
121
|
-
await client.v1.image_projects.delete(id="
|
|
259
|
+
await client.v1.image_projects.delete(id="cuid-example")
|
|
122
260
|
```
|
|
123
261
|
"""
|
|
124
262
|
await self._base_client.request(
|
|
@@ -131,7 +269,7 @@ class AsyncImageProjectsClient:
|
|
|
131
269
|
|
|
132
270
|
async def get(
|
|
133
271
|
self, *, id: str, request_options: typing.Optional[RequestOptions] = None
|
|
134
|
-
) -> models.
|
|
272
|
+
) -> models.V1ImageProjectsGetResponse:
|
|
135
273
|
"""
|
|
136
274
|
Get image details
|
|
137
275
|
|
|
@@ -149,7 +287,7 @@ class AsyncImageProjectsClient:
|
|
|
149
287
|
GET /v1/image-projects/{id}
|
|
150
288
|
|
|
151
289
|
Args:
|
|
152
|
-
id:
|
|
290
|
+
id: Unique ID of the image project. This value is returned by all of the POST APIs that create an image.
|
|
153
291
|
request_options: Additional options to customize the HTTP request
|
|
154
292
|
|
|
155
293
|
Returns:
|
|
@@ -161,13 +299,13 @@ class AsyncImageProjectsClient:
|
|
|
161
299
|
|
|
162
300
|
Examples:
|
|
163
301
|
```py
|
|
164
|
-
await client.v1.image_projects.get(id="
|
|
302
|
+
await client.v1.image_projects.get(id="cuid-example")
|
|
165
303
|
```
|
|
166
304
|
"""
|
|
167
305
|
return await self._base_client.request(
|
|
168
306
|
method="GET",
|
|
169
307
|
path=f"/v1/image-projects/{id}",
|
|
170
308
|
auth_names=["bearerAuth"],
|
|
171
|
-
cast_to=models.
|
|
309
|
+
cast_to=models.V1ImageProjectsGetResponse,
|
|
172
310
|
request_options=request_options or default_request_options(),
|
|
173
311
|
)
|