fastsdk 0.2.26__tar.gz → 0.2.28__tar.gz

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.
Files changed (36) hide show
  1. {fastsdk-0.2.26 → fastsdk-0.2.28}/PKG-INFO +1 -1
  2. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/__init__.py +14 -14
  3. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/fastClient.py +76 -76
  4. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/fastSDK.py +373 -373
  5. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/sdk_factory/sdk_factory.py +458 -458
  6. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/api_job_manager.py +54 -10
  7. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/api_seex.py +2 -2
  8. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/request/api_client.py +30 -50
  9. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/request/api_client_replicate.py +50 -50
  10. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/request/api_client_socaity.py +21 -9
  11. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/response/api_job_status.py +1 -0
  12. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/response/response_parser.py +35 -7
  13. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/response/response_parser_strategies.py +183 -183
  14. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk.egg-info/PKG-INFO +1 -1
  15. {fastsdk-0.2.26 → fastsdk-0.2.28}/pyproject.toml +1 -1
  16. {fastsdk-0.2.26 → fastsdk-0.2.28}/LICENSE +0 -0
  17. {fastsdk-0.2.26 → fastsdk-0.2.28}/README.md +0 -0
  18. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/sdk_factory/__init__.py +0 -0
  19. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/sdk_factory/sdk_template.j2 +0 -0
  20. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/__init__.py +0 -0
  21. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/request/__init__.py +0 -0
  22. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/request/api_client_runpod.py +0 -0
  23. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/request/file_handler.py +0 -0
  24. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_interaction/response/base_response.py +0 -0
  25. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_specification_loader/runpod_open_api_loader.py +0 -0
  26. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk/service_specification_loader/spec_loader.py +0 -0
  27. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk.egg-info/SOURCES.txt +0 -0
  28. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk.egg-info/dependency_links.txt +0 -0
  29. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk.egg-info/requires.txt +0 -0
  30. {fastsdk-0.2.26 → fastsdk-0.2.28}/fastsdk.egg-info/top_level.txt +0 -0
  31. {fastsdk-0.2.26 → fastsdk-0.2.28}/setup.cfg +0 -0
  32. {fastsdk-0.2.26 → fastsdk-0.2.28}/test/test_client_factory.py +0 -0
  33. {fastsdk-0.2.26 → fastsdk-0.2.28}/test/test_client_from_fastapi.py +0 -0
  34. {fastsdk-0.2.26 → fastsdk-0.2.28}/test/test_client_from_runpod_serverless.py +0 -0
  35. {fastsdk-0.2.26 → fastsdk-0.2.28}/test/test_httpx_api.py +0 -0
  36. {fastsdk-0.2.26 → fastsdk-0.2.28}/test/test_manual_sdk.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastsdk
3
- Version: 0.2.26
3
+ Version: 0.2.28
4
4
  Summary: Your SDK and model zoo for generative AI. Build AI-powered applications with ease.
5
5
  Author: SocAIty
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,14 +1,14 @@
1
- from media_toolkit import MediaFile, ImageFile, VideoFile, AudioFile
2
- from meseex import gather_results, gather_results_async
3
-
4
- from .sdk_factory import create_sdk
5
- from .service_interaction.api_seex import APISeex
6
- from .fastClient import FastClient
7
-
8
- from .fastSDK import FastSDK
9
-
10
-
11
- __all__ = [
12
- 'create_sdk', 'APISeex', 'FastClient', 'FastSDK',
13
- 'MediaFile', 'ImageFile', 'VideoFile', 'AudioFile', 'gather_results', 'gather_results_async'
14
- ]
1
+ from media_toolkit import MediaFile, ImageFile, VideoFile, AudioFile
2
+ from meseex import gather_results, gather_results_async
3
+
4
+ from .sdk_factory import create_sdk
5
+ from .service_interaction.api_seex import APISeex
6
+ from .fastClient import FastClient
7
+
8
+ from .fastSDK import FastSDK
9
+
10
+
11
+ __all__ = [
12
+ 'create_sdk', 'APISeex', 'FastClient', 'FastSDK',
13
+ 'MediaFile', 'ImageFile', 'VideoFile', 'AudioFile', 'gather_results', 'gather_results_async'
14
+ ]
@@ -1,76 +1,76 @@
1
- from apipod_registry.definitions.service_definitions import ServiceDefinition, ReplicateServiceAddress, RunpodServiceAddress, SocaityServiceAddress
2
- from fastsdk.fastSDK import FastSDK
3
- import os
4
-
5
- from typing import TYPE_CHECKING
6
- if TYPE_CHECKING:
7
- from fastsdk.service_interaction.api_seex import APISeex
8
-
9
-
10
- class FastClient:
11
- """
12
- Base class to inherit from when creating a client stub (SDK) for a service.
13
- Subclasses are usually generated by the SDK generator.
14
- """
15
- def __init__(self, service_name_or_id: str, api_key: str = None):
16
- """
17
- service_name_or_id: Used to find the service in the service manager.
18
- api_key: Optional api key to use for the service. If not provided, it will be tried to be loaded from the environment variables.
19
- """
20
- self.fsdk = FastSDK() # its a signleton, so if it was already created, it will be reused with all the loaded services
21
-
22
- self.service_definition = self.fsdk.service_registry.get_service(service_name_or_id)
23
-
24
- if not self.service_definition:
25
- raise ValueError(f"Service {service_name_or_id} not found in the library. Check if the service {service_name_or_id} was added to the library.")
26
-
27
- # try to get api key from global settings if not provided
28
- self.api_key = api_key or self._get_api_key()
29
- # This loads the service_def and creates the api_client and the file_handler in the ApiJobManager
30
- self.fsdk.api_job_manager.load_api_client(self.service_definition.id, self.api_key)
31
-
32
- def _get_api_key(self):
33
- # for global services
34
- if isinstance(self.service_definition.service_address, SocaityServiceAddress):
35
- return os.getenv("SOCAITY_API_KEY", None)
36
- elif isinstance(self.service_definition.service_address, RunpodServiceAddress):
37
- return os.getenv("RUNPOD_API_KEY", None)
38
- elif isinstance(self.service_definition.service_address, ReplicateServiceAddress):
39
- return os.getenv("REPLICATE_API_KEY", None)
40
-
41
- # for locals try by service_id
42
- return os.getenv(self.service_definition.id.upper() + "_API_KEY", None)
43
-
44
- def submit_job(self, endpoint_id: str, **kwargs) -> 'APISeex':
45
- return self.fsdk.api_job_manager.submit_job(self.service_definition.id, endpoint_id, data=kwargs)
46
-
47
-
48
- class DynamicFastClient(FastClient):
49
- """
50
- Create a fastClient from a service_definition directly instead of creating a sdk.py with the SDK generator.
51
- The service_definition is added (and stored) in the service manager.
52
- Do this, if you know all parameters of the service and you don't want a generated client_stub.
53
- """
54
- def __init__(self, service_spec: ServiceDefinition, api_key: str = None):
55
- """
56
- Args:
57
- service_spec: ServiceDefinition object to create client for
58
- api_key: Optional API key for the service
59
- """
60
- service_def = FastSDK().add_service(service_spec)
61
- super().__init__(service_def.id, api_key)
62
-
63
-
64
- class TemporaryFastClient(DynamicFastClient):
65
- """
66
- This client will be removed from the service manager when the client is deleted.
67
- The service is temporarily added to the service manager during the lifetime of this client.
68
- """
69
- def __del__(self):
70
- """Remove the service from the service manager when client is deleted."""
71
- if self.service_definition and hasattr(self, 'fsdk'):
72
- try:
73
- self.fsdk.service_registry.remove_service(self.service_definition.id)
74
- except Exception:
75
- # Ignore errors during cleanup (e.g., if FastSDK is already destroyed)
76
- pass
1
+ from apipod_registry.definitions.service_definitions import ServiceDefinition, ReplicateServiceAddress, RunpodServiceAddress, SocaityServiceAddress
2
+ from fastsdk.fastSDK import FastSDK
3
+ import os
4
+
5
+ from typing import TYPE_CHECKING
6
+ if TYPE_CHECKING:
7
+ from fastsdk.service_interaction.api_seex import APISeex
8
+
9
+
10
+ class FastClient:
11
+ """
12
+ Base class to inherit from when creating a client stub (SDK) for a service.
13
+ Subclasses are usually generated by the SDK generator.
14
+ """
15
+ def __init__(self, service_name_or_id: str, api_key: str = None):
16
+ """
17
+ service_name_or_id: Used to find the service in the service manager.
18
+ api_key: Optional api key to use for the service. If not provided, it will be tried to be loaded from the environment variables.
19
+ """
20
+ self.fsdk = FastSDK() # its a signleton, so if it was already created, it will be reused with all the loaded services
21
+
22
+ self.service_definition = self.fsdk.service_registry.get_service(service_name_or_id)
23
+
24
+ if not self.service_definition:
25
+ raise ValueError(f"Service {service_name_or_id} not found in the library. Check if the service {service_name_or_id} was added to the library.")
26
+
27
+ # try to get api key from global settings if not provided
28
+ self.api_key = api_key or self._get_api_key()
29
+ # This loads the service_def and creates the api_client and the file_handler in the ApiJobManager
30
+ self.fsdk.api_job_manager.load_api_client(self.service_definition.id, self.api_key)
31
+
32
+ def _get_api_key(self):
33
+ # for global services
34
+ if isinstance(self.service_definition.service_address, SocaityServiceAddress):
35
+ return os.getenv("SOCAITY_API_KEY", None)
36
+ elif isinstance(self.service_definition.service_address, RunpodServiceAddress):
37
+ return os.getenv("RUNPOD_API_KEY", None)
38
+ elif isinstance(self.service_definition.service_address, ReplicateServiceAddress):
39
+ return os.getenv("REPLICATE_API_KEY", None)
40
+
41
+ # for locals try by service_id
42
+ return os.getenv(self.service_definition.id.upper() + "_API_KEY", None)
43
+
44
+ def submit_job(self, endpoint_id: str, **kwargs) -> 'APISeex':
45
+ return self.fsdk.api_job_manager.submit_job(self.service_definition.id, endpoint_id, data=kwargs)
46
+
47
+
48
+ class DynamicFastClient(FastClient):
49
+ """
50
+ Create a fastClient from a service_definition directly instead of creating a sdk.py with the SDK generator.
51
+ The service_definition is added (and stored) in the service manager.
52
+ Do this, if you know all parameters of the service and you don't want a generated client_stub.
53
+ """
54
+ def __init__(self, service_spec: ServiceDefinition, api_key: str = None):
55
+ """
56
+ Args:
57
+ service_spec: ServiceDefinition object to create client for
58
+ api_key: Optional API key for the service
59
+ """
60
+ service_def = FastSDK().add_service(service_spec)
61
+ super().__init__(service_def.id, api_key)
62
+
63
+
64
+ class TemporaryFastClient(DynamicFastClient):
65
+ """
66
+ This client will be removed from the service manager when the client is deleted.
67
+ The service is temporarily added to the service manager during the lifetime of this client.
68
+ """
69
+ def __del__(self):
70
+ """Remove the service from the service manager when client is deleted."""
71
+ if self.service_definition and hasattr(self, 'fsdk'):
72
+ try:
73
+ self.fsdk.service_registry.remove_service(self.service_definition.id)
74
+ except Exception:
75
+ # Ignore errors during cleanup (e.g., if FastSDK is already destroyed)
76
+ pass