agenta 0.27.0__py3-none-any.whl → 0.27.0a0__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.

Potentially problematic release.


This version of agenta might be problematic. Click here for more details.

Files changed (68) hide show
  1. agenta/__init__.py +3 -23
  2. agenta/cli/helper.py +1 -5
  3. agenta/client/backend/__init__.py +0 -14
  4. agenta/client/backend/apps/client.py +20 -28
  5. agenta/client/backend/client.py +2 -25
  6. agenta/client/backend/containers/client.py +1 -5
  7. agenta/client/backend/core/__init__.py +1 -2
  8. agenta/client/backend/core/client_wrapper.py +6 -6
  9. agenta/client/backend/core/file.py +11 -33
  10. agenta/client/backend/core/http_client.py +18 -24
  11. agenta/client/backend/core/pydantic_utilities.py +29 -144
  12. agenta/client/backend/core/request_options.py +0 -3
  13. agenta/client/backend/core/serialization.py +42 -139
  14. agenta/client/backend/evaluations/client.py +2 -7
  15. agenta/client/backend/evaluators/client.py +1 -349
  16. agenta/client/backend/observability/client.py +2 -11
  17. agenta/client/backend/testsets/client.py +10 -10
  18. agenta/client/backend/types/__init__.py +0 -14
  19. agenta/client/backend/types/app.py +0 -1
  20. agenta/client/backend/types/app_variant_response.py +1 -3
  21. agenta/client/backend/types/create_span.py +2 -3
  22. agenta/client/backend/types/environment_output.py +0 -1
  23. agenta/client/backend/types/environment_output_extended.py +0 -1
  24. agenta/client/backend/types/evaluation.py +2 -1
  25. agenta/client/backend/types/evaluator.py +0 -2
  26. agenta/client/backend/types/evaluator_config.py +0 -1
  27. agenta/client/backend/types/human_evaluation.py +2 -1
  28. agenta/client/backend/types/llm_tokens.py +2 -2
  29. agenta/client/backend/types/span.py +0 -1
  30. agenta/client/backend/types/span_detail.py +1 -7
  31. agenta/client/backend/types/test_set_output_response.py +2 -5
  32. agenta/client/backend/types/trace_detail.py +1 -7
  33. agenta/client/backend/types/with_pagination.py +2 -4
  34. agenta/client/backend/variants/client.py +273 -1566
  35. agenta/docker/docker-assets/Dockerfile.cloud.template +1 -1
  36. agenta/sdk/__init__.py +5 -21
  37. agenta/sdk/agenta_init.py +29 -34
  38. agenta/sdk/config_manager.py +205 -0
  39. agenta/sdk/context/routing.py +5 -6
  40. agenta/sdk/decorators/routing.py +146 -158
  41. agenta/sdk/decorators/tracing.py +239 -206
  42. agenta/sdk/litellm/litellm.py +36 -47
  43. agenta/sdk/tracing/attributes.py +47 -7
  44. agenta/sdk/tracing/context.py +2 -5
  45. agenta/sdk/tracing/conventions.py +19 -25
  46. agenta/sdk/tracing/exporters.py +5 -17
  47. agenta/sdk/tracing/inline.py +146 -92
  48. agenta/sdk/tracing/processors.py +13 -65
  49. agenta/sdk/tracing/spans.py +4 -16
  50. agenta/sdk/tracing/tracing.py +65 -124
  51. agenta/sdk/types.py +2 -61
  52. agenta/sdk/utils/exceptions.py +5 -38
  53. {agenta-0.27.0.dist-info → agenta-0.27.0a0.dist-info}/METADATA +1 -1
  54. {agenta-0.27.0.dist-info → agenta-0.27.0a0.dist-info}/RECORD +56 -67
  55. agenta/client/backend/types/config_dto.py +0 -32
  56. agenta/client/backend/types/config_response_model.py +0 -32
  57. agenta/client/backend/types/evaluator_mapping_output_interface.py +0 -21
  58. agenta/client/backend/types/evaluator_output_interface.py +0 -21
  59. agenta/client/backend/types/lifecycle_dto.py +0 -24
  60. agenta/client/backend/types/reference_dto.py +0 -23
  61. agenta/client/backend/types/reference_request_model.py +0 -23
  62. agenta/sdk/managers/__init__.py +0 -6
  63. agenta/sdk/managers/config.py +0 -318
  64. agenta/sdk/managers/deployment.py +0 -45
  65. agenta/sdk/managers/shared.py +0 -639
  66. agenta/sdk/managers/variant.py +0 -182
  67. {agenta-0.27.0.dist-info → agenta-0.27.0a0.dist-info}/WHEEL +0 -0
  68. {agenta-0.27.0.dist-info → agenta-0.27.0a0.dist-info}/entry_points.txt +0 -0
@@ -16,12 +16,7 @@ from ..core.jsonable_encoder import jsonable_encoder
16
16
  from ..types.variant_action import VariantAction
17
17
  from ..types.docker_env_vars import DockerEnvVars
18
18
  from ..types.uri import Uri
19
- from ..core.serialization import convert_and_respect_annotation_metadata
20
19
  from ..types.app_variant_revision import AppVariantRevision
21
- from ..types.reference_request_model import ReferenceRequestModel
22
- from ..types.config_response_model import ConfigResponseModel
23
- from ..types.config_dto import ConfigDto
24
- from ..types.reference_dto import ReferenceDto
25
20
  from ..core.client_wrapper import AsyncClientWrapper
26
21
 
27
22
  # this is used as the default value for optional parameters
@@ -242,12 +237,8 @@ class VariantsClient:
242
237
  f"variants/{jsonable_encoder(variant_id)}",
243
238
  method="PUT",
244
239
  json={
245
- "action": convert_and_respect_annotation_metadata(
246
- object_=action, annotation=VariantAction, direction="write"
247
- ),
248
- "env_vars": convert_and_respect_annotation_metadata(
249
- object_=env_vars, annotation=DockerEnvVars, direction="write"
250
- ),
240
+ "action": action,
241
+ "env_vars": env_vars,
251
242
  },
252
243
  request_options=request_options,
253
244
  omit=OMIT,
@@ -707,55 +698,83 @@ class VariantsClient:
707
698
  raise ApiError(status_code=_response.status_code, body=_response.text)
708
699
  raise ApiError(status_code=_response.status_code, body=_response_json)
709
700
 
710
- def configs_add(
701
+
702
+ class AsyncVariantsClient:
703
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
704
+ self._client_wrapper = client_wrapper
705
+
706
+ async def add_variant_from_base_and_config(
711
707
  self,
712
708
  *,
713
- variant_ref: ReferenceRequestModel,
714
- application_ref: ReferenceRequestModel,
709
+ base_id: str,
710
+ new_variant_name: str,
711
+ new_config_name: str,
712
+ parameters: typing.Dict[str, typing.Optional[typing.Any]],
715
713
  request_options: typing.Optional[RequestOptions] = None,
716
- ) -> ConfigResponseModel:
714
+ ) -> AddVariantFromBaseAndConfigResponse:
717
715
  """
716
+ Add a new variant based on an existing one.
717
+ Same as POST /config
718
+
719
+ Args:
720
+ payload (AddVariantFromBasePayload): Payload containing base variant ID, new variant name, and parameters.
721
+ stoken_session (SessionContainer, optional): Session container. Defaults to result of verify_session().
722
+
723
+ Raises:
724
+ HTTPException: Raised if the variant could not be added or accessed.
725
+
726
+ Returns:
727
+ Union[AppVariantResponse, Any]: New variant details or exception.
728
+
718
729
  Parameters
719
730
  ----------
720
- variant_ref : ReferenceRequestModel
731
+ base_id : str
732
+
733
+ new_variant_name : str
734
+
735
+ new_config_name : str
721
736
 
722
- application_ref : ReferenceRequestModel
737
+ parameters : typing.Dict[str, typing.Optional[typing.Any]]
723
738
 
724
739
  request_options : typing.Optional[RequestOptions]
725
740
  Request-specific configuration.
726
741
 
727
742
  Returns
728
743
  -------
729
- ConfigResponseModel
744
+ AddVariantFromBaseAndConfigResponse
730
745
  Successful Response
731
746
 
732
747
  Examples
733
748
  --------
734
- from agenta import AgentaApi, ReferenceRequestModel
749
+ import asyncio
735
750
 
736
- client = AgentaApi(
751
+ from agenta import AsyncAgentaApi
752
+
753
+ client = AsyncAgentaApi(
737
754
  api_key="YOUR_API_KEY",
738
755
  base_url="https://yourhost.com/path/to/api",
739
756
  )
740
- client.variants.configs_add(
741
- variant_ref=ReferenceRequestModel(),
742
- application_ref=ReferenceRequestModel(),
743
- )
757
+
758
+
759
+ async def main() -> None:
760
+ await client.variants.add_variant_from_base_and_config(
761
+ base_id="base_id",
762
+ new_variant_name="new_variant_name",
763
+ new_config_name="new_config_name",
764
+ parameters={"key": "value"},
765
+ )
766
+
767
+
768
+ asyncio.run(main())
744
769
  """
745
- _response = self._client_wrapper.httpx_client.request(
746
- "variants/configs/add",
770
+ _response = await self._client_wrapper.httpx_client.request(
771
+ "variants/from-base",
747
772
  method="POST",
748
773
  json={
749
- "variant_ref": convert_and_respect_annotation_metadata(
750
- object_=variant_ref,
751
- annotation=ReferenceRequestModel,
752
- direction="write",
753
- ),
754
- "application_ref": convert_and_respect_annotation_metadata(
755
- object_=application_ref,
756
- annotation=ReferenceRequestModel,
757
- direction="write",
758
- ),
774
+ "base_id": base_id,
775
+ "new_variant_name": new_variant_name,
776
+ "new_config_name": new_config_name,
777
+ "parameters": parameters,
759
778
  },
760
779
  request_options=request_options,
761
780
  omit=OMIT,
@@ -763,9 +782,9 @@ class VariantsClient:
763
782
  try:
764
783
  if 200 <= _response.status_code < 300:
765
784
  return typing.cast(
766
- ConfigResponseModel,
785
+ AddVariantFromBaseAndConfigResponse,
767
786
  parse_obj_as(
768
- type_=ConfigResponseModel, # type: ignore
787
+ type_=AddVariantFromBaseAndConfigResponse, # type: ignore
769
788
  object_=_response.json(),
770
789
  ),
771
790
  )
@@ -784,70 +803,56 @@ class VariantsClient:
784
803
  raise ApiError(status_code=_response.status_code, body=_response.text)
785
804
  raise ApiError(status_code=_response.status_code, body=_response_json)
786
805
 
787
- def configs_fetch(
806
+ async def get_variant(
788
807
  self,
808
+ variant_id: str,
789
809
  *,
790
- variant_ref: typing.Optional[ReferenceRequestModel] = OMIT,
791
- environment_ref: typing.Optional[ReferenceRequestModel] = OMIT,
792
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
793
810
  request_options: typing.Optional[RequestOptions] = None,
794
- ) -> ConfigResponseModel:
811
+ ) -> AppVariantResponse:
795
812
  """
796
813
  Parameters
797
814
  ----------
798
- variant_ref : typing.Optional[ReferenceRequestModel]
799
-
800
- environment_ref : typing.Optional[ReferenceRequestModel]
801
-
802
- application_ref : typing.Optional[ReferenceRequestModel]
815
+ variant_id : str
803
816
 
804
817
  request_options : typing.Optional[RequestOptions]
805
818
  Request-specific configuration.
806
819
 
807
820
  Returns
808
821
  -------
809
- ConfigResponseModel
822
+ AppVariantResponse
810
823
  Successful Response
811
824
 
812
825
  Examples
813
826
  --------
814
- from agenta import AgentaApi
827
+ import asyncio
815
828
 
816
- client = AgentaApi(
829
+ from agenta import AsyncAgentaApi
830
+
831
+ client = AsyncAgentaApi(
817
832
  api_key="YOUR_API_KEY",
818
833
  base_url="https://yourhost.com/path/to/api",
819
834
  )
820
- client.variants.configs_fetch()
835
+
836
+
837
+ async def main() -> None:
838
+ await client.variants.get_variant(
839
+ variant_id="variant_id",
840
+ )
841
+
842
+
843
+ asyncio.run(main())
821
844
  """
822
- _response = self._client_wrapper.httpx_client.request(
823
- "variants/configs/fetch",
824
- method="POST",
825
- json={
826
- "variant_ref": convert_and_respect_annotation_metadata(
827
- object_=variant_ref,
828
- annotation=ReferenceRequestModel,
829
- direction="write",
830
- ),
831
- "environment_ref": convert_and_respect_annotation_metadata(
832
- object_=environment_ref,
833
- annotation=ReferenceRequestModel,
834
- direction="write",
835
- ),
836
- "application_ref": convert_and_respect_annotation_metadata(
837
- object_=application_ref,
838
- annotation=ReferenceRequestModel,
839
- direction="write",
840
- ),
841
- },
845
+ _response = await self._client_wrapper.httpx_client.request(
846
+ f"variants/{jsonable_encoder(variant_id)}",
847
+ method="GET",
842
848
  request_options=request_options,
843
- omit=OMIT,
844
849
  )
845
850
  try:
846
851
  if 200 <= _response.status_code < 300:
847
852
  return typing.cast(
848
- ConfigResponseModel,
853
+ AppVariantResponse,
849
854
  parse_obj_as(
850
- type_=ConfigResponseModel, # type: ignore
855
+ type_=AppVariantResponse, # type: ignore
851
856
  object_=_response.json(),
852
857
  ),
853
858
  )
@@ -866,60 +871,74 @@ class VariantsClient:
866
871
  raise ApiError(status_code=_response.status_code, body=_response.text)
867
872
  raise ApiError(status_code=_response.status_code, body=_response_json)
868
873
 
869
- def configs_fork(
874
+ async def start_variant(
870
875
  self,
876
+ variant_id: str,
871
877
  *,
872
- variant_ref: typing.Optional[ReferenceRequestModel] = OMIT,
873
- environment_ref: typing.Optional[ReferenceRequestModel] = OMIT,
874
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
878
+ action: VariantAction,
879
+ env_vars: typing.Optional[DockerEnvVars] = OMIT,
875
880
  request_options: typing.Optional[RequestOptions] = None,
876
- ) -> ConfigResponseModel:
881
+ ) -> Uri:
877
882
  """
883
+ Start a variant of an app.
884
+
885
+ Args:
886
+ variant_id (str): The ID of the variant to start.
887
+ action (VariantAction): The action to perform on the variant (start).
888
+ env_vars (Optional[DockerEnvVars], optional): The environment variables to inject to the Docker container. Defaults to None.
889
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
890
+
891
+ Returns:
892
+ URI: The URL of the started variant.
893
+
894
+ Raises:
895
+ HTTPException: If the app container cannot be started.
896
+
878
897
  Parameters
879
898
  ----------
880
- variant_ref : typing.Optional[ReferenceRequestModel]
899
+ variant_id : str
881
900
 
882
- environment_ref : typing.Optional[ReferenceRequestModel]
901
+ action : VariantAction
883
902
 
884
- application_ref : typing.Optional[ReferenceRequestModel]
903
+ env_vars : typing.Optional[DockerEnvVars]
885
904
 
886
905
  request_options : typing.Optional[RequestOptions]
887
906
  Request-specific configuration.
888
907
 
889
908
  Returns
890
909
  -------
891
- ConfigResponseModel
910
+ Uri
892
911
  Successful Response
893
912
 
894
913
  Examples
895
914
  --------
896
- from agenta import AgentaApi
915
+ import asyncio
897
916
 
898
- client = AgentaApi(
917
+ from agenta import AsyncAgentaApi, VariantAction
918
+
919
+ client = AsyncAgentaApi(
899
920
  api_key="YOUR_API_KEY",
900
921
  base_url="https://yourhost.com/path/to/api",
901
922
  )
902
- client.variants.configs_fork()
923
+
924
+
925
+ async def main() -> None:
926
+ await client.variants.start_variant(
927
+ variant_id="variant_id",
928
+ action=VariantAction(
929
+ action="START",
930
+ ),
931
+ )
932
+
933
+
934
+ asyncio.run(main())
903
935
  """
904
- _response = self._client_wrapper.httpx_client.request(
905
- "variants/configs/fork",
906
- method="POST",
936
+ _response = await self._client_wrapper.httpx_client.request(
937
+ f"variants/{jsonable_encoder(variant_id)}",
938
+ method="PUT",
907
939
  json={
908
- "variant_ref": convert_and_respect_annotation_metadata(
909
- object_=variant_ref,
910
- annotation=ReferenceRequestModel,
911
- direction="write",
912
- ),
913
- "environment_ref": convert_and_respect_annotation_metadata(
914
- object_=environment_ref,
915
- annotation=ReferenceRequestModel,
916
- direction="write",
917
- ),
918
- "application_ref": convert_and_respect_annotation_metadata(
919
- object_=application_ref,
920
- annotation=ReferenceRequestModel,
921
- direction="write",
922
- ),
940
+ "action": action,
941
+ "env_vars": env_vars,
923
942
  },
924
943
  request_options=request_options,
925
944
  omit=OMIT,
@@ -927,9 +946,9 @@ class VariantsClient:
927
946
  try:
928
947
  if 200 <= _response.status_code < 300:
929
948
  return typing.cast(
930
- ConfigResponseModel,
949
+ Uri,
931
950
  parse_obj_as(
932
- type_=ConfigResponseModel, # type: ignore
951
+ type_=Uri, # type: ignore
933
952
  object_=_response.json(),
934
953
  ),
935
954
  )
@@ -948,56 +967,65 @@ class VariantsClient:
948
967
  raise ApiError(status_code=_response.status_code, body=_response.text)
949
968
  raise ApiError(status_code=_response.status_code, body=_response_json)
950
969
 
951
- def configs_commit(
970
+ async def remove_variant(
952
971
  self,
972
+ variant_id: str,
953
973
  *,
954
- config: ConfigDto,
955
974
  request_options: typing.Optional[RequestOptions] = None,
956
- ) -> ConfigResponseModel:
975
+ ) -> typing.Optional[typing.Any]:
957
976
  """
977
+ Remove a variant from the server.
978
+ In the case it's the last variant using the image, stop the container and remove the image.
979
+
980
+ Arguments:
981
+ app_variant -- AppVariant to remove
982
+
983
+ Raises:
984
+ HTTPException: If there is a problem removing the app variant
985
+
958
986
  Parameters
959
987
  ----------
960
- config : ConfigDto
988
+ variant_id : str
961
989
 
962
990
  request_options : typing.Optional[RequestOptions]
963
991
  Request-specific configuration.
964
992
 
965
993
  Returns
966
994
  -------
967
- ConfigResponseModel
995
+ typing.Optional[typing.Any]
968
996
  Successful Response
969
997
 
970
998
  Examples
971
999
  --------
972
- from agenta import AgentaApi, ConfigDto
1000
+ import asyncio
973
1001
 
974
- client = AgentaApi(
1002
+ from agenta import AsyncAgentaApi
1003
+
1004
+ client = AsyncAgentaApi(
975
1005
  api_key="YOUR_API_KEY",
976
1006
  base_url="https://yourhost.com/path/to/api",
977
1007
  )
978
- client.variants.configs_commit(
979
- config=ConfigDto(
980
- params={"key": "value"},
981
- ),
982
- )
1008
+
1009
+
1010
+ async def main() -> None:
1011
+ await client.variants.remove_variant(
1012
+ variant_id="variant_id",
1013
+ )
1014
+
1015
+
1016
+ asyncio.run(main())
983
1017
  """
984
- _response = self._client_wrapper.httpx_client.request(
985
- "variants/configs/commit",
986
- method="POST",
987
- json={
988
- "config": convert_and_respect_annotation_metadata(
989
- object_=config, annotation=ConfigDto, direction="write"
990
- ),
991
- },
1018
+ _response = await self._client_wrapper.httpx_client.request(
1019
+ f"variants/{jsonable_encoder(variant_id)}",
1020
+ method="DELETE",
992
1021
  request_options=request_options,
993
- omit=OMIT,
994
1022
  )
995
1023
  try:
996
1024
  if 200 <= _response.status_code < 300:
997
1025
  return typing.cast(
998
- ConfigResponseModel,
1026
+ typing.Optional[typing.Any],
999
1027
  parse_obj_as(
1000
- type_=ConfigResponseModel, # type: ignore
1028
+ type_=typing.Optional[typing.Any], # type: ignore
1001
1029
  object_=_response.json(),
1002
1030
  ),
1003
1031
  )
@@ -1016,63 +1044,67 @@ class VariantsClient:
1016
1044
  raise ApiError(status_code=_response.status_code, body=_response.text)
1017
1045
  raise ApiError(status_code=_response.status_code, body=_response_json)
1018
1046
 
1019
- def configs_deploy(
1047
+ async def update_variant_parameters(
1020
1048
  self,
1049
+ variant_id: str,
1021
1050
  *,
1022
- variant_ref: ReferenceRequestModel,
1023
- environment_ref: ReferenceRequestModel,
1024
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
1051
+ parameters: typing.Dict[str, typing.Optional[typing.Any]],
1025
1052
  request_options: typing.Optional[RequestOptions] = None,
1026
- ) -> ConfigResponseModel:
1053
+ ) -> typing.Optional[typing.Any]:
1027
1054
  """
1055
+ Updates the parameters for an app variant.
1056
+
1057
+ Args:
1058
+ variant_id (str): The ID of the app variant to update.
1059
+ payload (UpdateVariantParameterPayload): The payload containing the updated parameters.
1060
+ stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1061
+
1062
+ Raises:
1063
+ HTTPException: If there is an error while trying to update the app variant.
1064
+
1065
+ Returns:
1066
+ JSONResponse: A JSON response containing the updated app variant parameters.
1067
+
1028
1068
  Parameters
1029
1069
  ----------
1030
- variant_ref : ReferenceRequestModel
1031
-
1032
- environment_ref : ReferenceRequestModel
1070
+ variant_id : str
1033
1071
 
1034
- application_ref : typing.Optional[ReferenceRequestModel]
1072
+ parameters : typing.Dict[str, typing.Optional[typing.Any]]
1035
1073
 
1036
1074
  request_options : typing.Optional[RequestOptions]
1037
1075
  Request-specific configuration.
1038
1076
 
1039
1077
  Returns
1040
1078
  -------
1041
- ConfigResponseModel
1079
+ typing.Optional[typing.Any]
1042
1080
  Successful Response
1043
1081
 
1044
1082
  Examples
1045
1083
  --------
1046
- from agenta import AgentaApi, ReferenceRequestModel
1084
+ import asyncio
1047
1085
 
1048
- client = AgentaApi(
1086
+ from agenta import AsyncAgentaApi
1087
+
1088
+ client = AsyncAgentaApi(
1049
1089
  api_key="YOUR_API_KEY",
1050
1090
  base_url="https://yourhost.com/path/to/api",
1051
1091
  )
1052
- client.variants.configs_deploy(
1053
- variant_ref=ReferenceRequestModel(),
1054
- environment_ref=ReferenceRequestModel(),
1055
- )
1092
+
1093
+
1094
+ async def main() -> None:
1095
+ await client.variants.update_variant_parameters(
1096
+ variant_id="variant_id",
1097
+ parameters={"key": "value"},
1098
+ )
1099
+
1100
+
1101
+ asyncio.run(main())
1056
1102
  """
1057
- _response = self._client_wrapper.httpx_client.request(
1058
- "variants/configs/deploy",
1059
- method="POST",
1103
+ _response = await self._client_wrapper.httpx_client.request(
1104
+ f"variants/{jsonable_encoder(variant_id)}/parameters",
1105
+ method="PUT",
1060
1106
  json={
1061
- "variant_ref": convert_and_respect_annotation_metadata(
1062
- object_=variant_ref,
1063
- annotation=ReferenceRequestModel,
1064
- direction="write",
1065
- ),
1066
- "environment_ref": convert_and_respect_annotation_metadata(
1067
- object_=environment_ref,
1068
- annotation=ReferenceRequestModel,
1069
- direction="write",
1070
- ),
1071
- "application_ref": convert_and_respect_annotation_metadata(
1072
- object_=application_ref,
1073
- annotation=ReferenceRequestModel,
1074
- direction="write",
1075
- ),
1107
+ "parameters": parameters,
1076
1108
  },
1077
1109
  request_options=request_options,
1078
1110
  omit=OMIT,
@@ -1080,9 +1112,9 @@ class VariantsClient:
1080
1112
  try:
1081
1113
  if 200 <= _response.status_code < 300:
1082
1114
  return typing.cast(
1083
- ConfigResponseModel,
1115
+ typing.Optional[typing.Any],
1084
1116
  parse_obj_as(
1085
- type_=ConfigResponseModel, # type: ignore
1117
+ type_=typing.Optional[typing.Any], # type: ignore
1086
1118
  object_=_response.json(),
1087
1119
  ),
1088
1120
  )
@@ -1101,1261 +1133,57 @@ class VariantsClient:
1101
1133
  raise ApiError(status_code=_response.status_code, body=_response.text)
1102
1134
  raise ApiError(status_code=_response.status_code, body=_response_json)
1103
1135
 
1104
- def configs_delete(
1136
+ async def update_variant_image(
1105
1137
  self,
1138
+ variant_id: str,
1106
1139
  *,
1107
- variant_ref: typing.Optional[ReferenceRequestModel] = OMIT,
1108
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
1140
+ docker_id: str,
1141
+ tags: str,
1142
+ type: typing.Optional[str] = OMIT,
1143
+ organization_id: typing.Optional[str] = OMIT,
1144
+ workspace_id: typing.Optional[str] = OMIT,
1109
1145
  request_options: typing.Optional[RequestOptions] = None,
1110
- ) -> int:
1146
+ ) -> typing.Optional[typing.Any]:
1111
1147
  """
1112
- Parameters
1113
- ----------
1114
- variant_ref : typing.Optional[ReferenceRequestModel]
1148
+ Updates the image used in an app variant.
1115
1149
 
1116
- application_ref : typing.Optional[ReferenceRequestModel]
1150
+ Args:
1151
+ variant_id (str): The ID of the app variant to update.
1152
+ image (Image): The image information to update.
1117
1153
 
1118
- request_options : typing.Optional[RequestOptions]
1119
- Request-specific configuration.
1154
+ Raises:
1155
+ HTTPException: If an error occurs while trying to update the app variant.
1120
1156
 
1121
- Returns
1122
- -------
1123
- int
1124
- Successful Response
1125
-
1126
- Examples
1127
- --------
1128
- from agenta import AgentaApi
1129
-
1130
- client = AgentaApi(
1131
- api_key="YOUR_API_KEY",
1132
- base_url="https://yourhost.com/path/to/api",
1133
- )
1134
- client.variants.configs_delete()
1135
- """
1136
- _response = self._client_wrapper.httpx_client.request(
1137
- "variants/configs/delete",
1138
- method="POST",
1139
- json={
1140
- "variant_ref": convert_and_respect_annotation_metadata(
1141
- object_=variant_ref,
1142
- annotation=ReferenceRequestModel,
1143
- direction="write",
1144
- ),
1145
- "application_ref": convert_and_respect_annotation_metadata(
1146
- object_=application_ref,
1147
- annotation=ReferenceRequestModel,
1148
- direction="write",
1149
- ),
1150
- },
1151
- request_options=request_options,
1152
- omit=OMIT,
1153
- )
1154
- try:
1155
- if 200 <= _response.status_code < 300:
1156
- return typing.cast(
1157
- int,
1158
- parse_obj_as(
1159
- type_=int, # type: ignore
1160
- object_=_response.json(),
1161
- ),
1162
- )
1163
- if _response.status_code == 422:
1164
- raise UnprocessableEntityError(
1165
- typing.cast(
1166
- HttpValidationError,
1167
- parse_obj_as(
1168
- type_=HttpValidationError, # type: ignore
1169
- object_=_response.json(),
1170
- ),
1171
- )
1172
- )
1173
- _response_json = _response.json()
1174
- except JSONDecodeError:
1175
- raise ApiError(status_code=_response.status_code, body=_response.text)
1176
- raise ApiError(status_code=_response.status_code, body=_response_json)
1177
-
1178
- def configs_list(
1179
- self,
1180
- *,
1181
- application_ref: ReferenceDto,
1182
- request_options: typing.Optional[RequestOptions] = None,
1183
- ) -> typing.List[ConfigResponseModel]:
1184
- """
1185
- Parameters
1186
- ----------
1187
- application_ref : ReferenceDto
1188
-
1189
- request_options : typing.Optional[RequestOptions]
1190
- Request-specific configuration.
1191
-
1192
- Returns
1193
- -------
1194
- typing.List[ConfigResponseModel]
1195
- Successful Response
1196
-
1197
- Examples
1198
- --------
1199
- from agenta import AgentaApi, ReferenceDto
1200
-
1201
- client = AgentaApi(
1202
- api_key="YOUR_API_KEY",
1203
- base_url="https://yourhost.com/path/to/api",
1204
- )
1205
- client.variants.configs_list(
1206
- application_ref=ReferenceDto(),
1207
- )
1208
- """
1209
- _response = self._client_wrapper.httpx_client.request(
1210
- "variants/configs/list",
1211
- method="POST",
1212
- json={
1213
- "application_ref": convert_and_respect_annotation_metadata(
1214
- object_=application_ref, annotation=ReferenceDto, direction="write"
1215
- ),
1216
- },
1217
- request_options=request_options,
1218
- omit=OMIT,
1219
- )
1220
- try:
1221
- if 200 <= _response.status_code < 300:
1222
- return typing.cast(
1223
- typing.List[ConfigResponseModel],
1224
- parse_obj_as(
1225
- type_=typing.List[ConfigResponseModel], # type: ignore
1226
- object_=_response.json(),
1227
- ),
1228
- )
1229
- if _response.status_code == 422:
1230
- raise UnprocessableEntityError(
1231
- typing.cast(
1232
- HttpValidationError,
1233
- parse_obj_as(
1234
- type_=HttpValidationError, # type: ignore
1235
- object_=_response.json(),
1236
- ),
1237
- )
1238
- )
1239
- _response_json = _response.json()
1240
- except JSONDecodeError:
1241
- raise ApiError(status_code=_response.status_code, body=_response.text)
1242
- raise ApiError(status_code=_response.status_code, body=_response_json)
1243
-
1244
- def configs_history(
1245
- self,
1246
- *,
1247
- variant_ref: typing.Optional[ReferenceRequestModel] = OMIT,
1248
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
1249
- request_options: typing.Optional[RequestOptions] = None,
1250
- ) -> typing.List[ConfigResponseModel]:
1251
- """
1252
- Parameters
1253
- ----------
1254
- variant_ref : typing.Optional[ReferenceRequestModel]
1255
-
1256
- application_ref : typing.Optional[ReferenceRequestModel]
1257
-
1258
- request_options : typing.Optional[RequestOptions]
1259
- Request-specific configuration.
1260
-
1261
- Returns
1262
- -------
1263
- typing.List[ConfigResponseModel]
1264
- Successful Response
1265
-
1266
- Examples
1267
- --------
1268
- from agenta import AgentaApi
1269
-
1270
- client = AgentaApi(
1271
- api_key="YOUR_API_KEY",
1272
- base_url="https://yourhost.com/path/to/api",
1273
- )
1274
- client.variants.configs_history()
1275
- """
1276
- _response = self._client_wrapper.httpx_client.request(
1277
- "variants/configs/history",
1278
- method="POST",
1279
- json={
1280
- "variant_ref": convert_and_respect_annotation_metadata(
1281
- object_=variant_ref,
1282
- annotation=ReferenceRequestModel,
1283
- direction="write",
1284
- ),
1285
- "application_ref": convert_and_respect_annotation_metadata(
1286
- object_=application_ref,
1287
- annotation=ReferenceRequestModel,
1288
- direction="write",
1289
- ),
1290
- },
1291
- request_options=request_options,
1292
- omit=OMIT,
1293
- )
1294
- try:
1295
- if 200 <= _response.status_code < 300:
1296
- return typing.cast(
1297
- typing.List[ConfigResponseModel],
1298
- parse_obj_as(
1299
- type_=typing.List[ConfigResponseModel], # type: ignore
1300
- object_=_response.json(),
1301
- ),
1302
- )
1303
- if _response.status_code == 422:
1304
- raise UnprocessableEntityError(
1305
- typing.cast(
1306
- HttpValidationError,
1307
- parse_obj_as(
1308
- type_=HttpValidationError, # type: ignore
1309
- object_=_response.json(),
1310
- ),
1311
- )
1312
- )
1313
- _response_json = _response.json()
1314
- except JSONDecodeError:
1315
- raise ApiError(status_code=_response.status_code, body=_response.text)
1316
- raise ApiError(status_code=_response.status_code, body=_response_json)
1317
-
1318
-
1319
- class AsyncVariantsClient:
1320
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
1321
- self._client_wrapper = client_wrapper
1322
-
1323
- async def add_variant_from_base_and_config(
1324
- self,
1325
- *,
1326
- base_id: str,
1327
- new_variant_name: str,
1328
- new_config_name: str,
1329
- parameters: typing.Dict[str, typing.Optional[typing.Any]],
1330
- request_options: typing.Optional[RequestOptions] = None,
1331
- ) -> AddVariantFromBaseAndConfigResponse:
1332
- """
1333
- Add a new variant based on an existing one.
1334
- Same as POST /config
1335
-
1336
- Args:
1337
- payload (AddVariantFromBasePayload): Payload containing base variant ID, new variant name, and parameters.
1338
- stoken_session (SessionContainer, optional): Session container. Defaults to result of verify_session().
1339
-
1340
- Raises:
1341
- HTTPException: Raised if the variant could not be added or accessed.
1342
-
1343
- Returns:
1344
- Union[AppVariantResponse, Any]: New variant details or exception.
1345
-
1346
- Parameters
1347
- ----------
1348
- base_id : str
1349
-
1350
- new_variant_name : str
1351
-
1352
- new_config_name : str
1353
-
1354
- parameters : typing.Dict[str, typing.Optional[typing.Any]]
1355
-
1356
- request_options : typing.Optional[RequestOptions]
1357
- Request-specific configuration.
1358
-
1359
- Returns
1360
- -------
1361
- AddVariantFromBaseAndConfigResponse
1362
- Successful Response
1363
-
1364
- Examples
1365
- --------
1366
- import asyncio
1367
-
1368
- from agenta import AsyncAgentaApi
1369
-
1370
- client = AsyncAgentaApi(
1371
- api_key="YOUR_API_KEY",
1372
- base_url="https://yourhost.com/path/to/api",
1373
- )
1374
-
1375
-
1376
- async def main() -> None:
1377
- await client.variants.add_variant_from_base_and_config(
1378
- base_id="base_id",
1379
- new_variant_name="new_variant_name",
1380
- new_config_name="new_config_name",
1381
- parameters={"key": "value"},
1382
- )
1383
-
1384
-
1385
- asyncio.run(main())
1386
- """
1387
- _response = await self._client_wrapper.httpx_client.request(
1388
- "variants/from-base",
1389
- method="POST",
1390
- json={
1391
- "base_id": base_id,
1392
- "new_variant_name": new_variant_name,
1393
- "new_config_name": new_config_name,
1394
- "parameters": parameters,
1395
- },
1396
- request_options=request_options,
1397
- omit=OMIT,
1398
- )
1399
- try:
1400
- if 200 <= _response.status_code < 300:
1401
- return typing.cast(
1402
- AddVariantFromBaseAndConfigResponse,
1403
- parse_obj_as(
1404
- type_=AddVariantFromBaseAndConfigResponse, # type: ignore
1405
- object_=_response.json(),
1406
- ),
1407
- )
1408
- if _response.status_code == 422:
1409
- raise UnprocessableEntityError(
1410
- typing.cast(
1411
- HttpValidationError,
1412
- parse_obj_as(
1413
- type_=HttpValidationError, # type: ignore
1414
- object_=_response.json(),
1415
- ),
1416
- )
1417
- )
1418
- _response_json = _response.json()
1419
- except JSONDecodeError:
1420
- raise ApiError(status_code=_response.status_code, body=_response.text)
1421
- raise ApiError(status_code=_response.status_code, body=_response_json)
1422
-
1423
- async def get_variant(
1424
- self,
1425
- variant_id: str,
1426
- *,
1427
- request_options: typing.Optional[RequestOptions] = None,
1428
- ) -> AppVariantResponse:
1429
- """
1430
- Parameters
1431
- ----------
1432
- variant_id : str
1433
-
1434
- request_options : typing.Optional[RequestOptions]
1435
- Request-specific configuration.
1436
-
1437
- Returns
1438
- -------
1439
- AppVariantResponse
1440
- Successful Response
1441
-
1442
- Examples
1443
- --------
1444
- import asyncio
1445
-
1446
- from agenta import AsyncAgentaApi
1447
-
1448
- client = AsyncAgentaApi(
1449
- api_key="YOUR_API_KEY",
1450
- base_url="https://yourhost.com/path/to/api",
1451
- )
1452
-
1453
-
1454
- async def main() -> None:
1455
- await client.variants.get_variant(
1456
- variant_id="variant_id",
1457
- )
1458
-
1459
-
1460
- asyncio.run(main())
1461
- """
1462
- _response = await self._client_wrapper.httpx_client.request(
1463
- f"variants/{jsonable_encoder(variant_id)}",
1464
- method="GET",
1465
- request_options=request_options,
1466
- )
1467
- try:
1468
- if 200 <= _response.status_code < 300:
1469
- return typing.cast(
1470
- AppVariantResponse,
1471
- parse_obj_as(
1472
- type_=AppVariantResponse, # type: ignore
1473
- object_=_response.json(),
1474
- ),
1475
- )
1476
- if _response.status_code == 422:
1477
- raise UnprocessableEntityError(
1478
- typing.cast(
1479
- HttpValidationError,
1480
- parse_obj_as(
1481
- type_=HttpValidationError, # type: ignore
1482
- object_=_response.json(),
1483
- ),
1484
- )
1485
- )
1486
- _response_json = _response.json()
1487
- except JSONDecodeError:
1488
- raise ApiError(status_code=_response.status_code, body=_response.text)
1489
- raise ApiError(status_code=_response.status_code, body=_response_json)
1490
-
1491
- async def start_variant(
1492
- self,
1493
- variant_id: str,
1494
- *,
1495
- action: VariantAction,
1496
- env_vars: typing.Optional[DockerEnvVars] = OMIT,
1497
- request_options: typing.Optional[RequestOptions] = None,
1498
- ) -> Uri:
1499
- """
1500
- Start a variant of an app.
1501
-
1502
- Args:
1503
- variant_id (str): The ID of the variant to start.
1504
- action (VariantAction): The action to perform on the variant (start).
1505
- env_vars (Optional[DockerEnvVars], optional): The environment variables to inject to the Docker container. Defaults to None.
1506
- stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1507
-
1508
- Returns:
1509
- URI: The URL of the started variant.
1510
-
1511
- Raises:
1512
- HTTPException: If the app container cannot be started.
1513
-
1514
- Parameters
1515
- ----------
1516
- variant_id : str
1517
-
1518
- action : VariantAction
1519
-
1520
- env_vars : typing.Optional[DockerEnvVars]
1521
-
1522
- request_options : typing.Optional[RequestOptions]
1523
- Request-specific configuration.
1524
-
1525
- Returns
1526
- -------
1527
- Uri
1528
- Successful Response
1529
-
1530
- Examples
1531
- --------
1532
- import asyncio
1533
-
1534
- from agenta import AsyncAgentaApi, VariantAction
1535
-
1536
- client = AsyncAgentaApi(
1537
- api_key="YOUR_API_KEY",
1538
- base_url="https://yourhost.com/path/to/api",
1539
- )
1540
-
1541
-
1542
- async def main() -> None:
1543
- await client.variants.start_variant(
1544
- variant_id="variant_id",
1545
- action=VariantAction(
1546
- action="START",
1547
- ),
1548
- )
1549
-
1550
-
1551
- asyncio.run(main())
1552
- """
1553
- _response = await self._client_wrapper.httpx_client.request(
1554
- f"variants/{jsonable_encoder(variant_id)}",
1555
- method="PUT",
1556
- json={
1557
- "action": convert_and_respect_annotation_metadata(
1558
- object_=action, annotation=VariantAction, direction="write"
1559
- ),
1560
- "env_vars": convert_and_respect_annotation_metadata(
1561
- object_=env_vars, annotation=DockerEnvVars, direction="write"
1562
- ),
1563
- },
1564
- request_options=request_options,
1565
- omit=OMIT,
1566
- )
1567
- try:
1568
- if 200 <= _response.status_code < 300:
1569
- return typing.cast(
1570
- Uri,
1571
- parse_obj_as(
1572
- type_=Uri, # type: ignore
1573
- object_=_response.json(),
1574
- ),
1575
- )
1576
- if _response.status_code == 422:
1577
- raise UnprocessableEntityError(
1578
- typing.cast(
1579
- HttpValidationError,
1580
- parse_obj_as(
1581
- type_=HttpValidationError, # type: ignore
1582
- object_=_response.json(),
1583
- ),
1584
- )
1585
- )
1586
- _response_json = _response.json()
1587
- except JSONDecodeError:
1588
- raise ApiError(status_code=_response.status_code, body=_response.text)
1589
- raise ApiError(status_code=_response.status_code, body=_response_json)
1590
-
1591
- async def remove_variant(
1592
- self,
1593
- variant_id: str,
1594
- *,
1595
- request_options: typing.Optional[RequestOptions] = None,
1596
- ) -> typing.Optional[typing.Any]:
1597
- """
1598
- Remove a variant from the server.
1599
- In the case it's the last variant using the image, stop the container and remove the image.
1600
-
1601
- Arguments:
1602
- app_variant -- AppVariant to remove
1603
-
1604
- Raises:
1605
- HTTPException: If there is a problem removing the app variant
1606
-
1607
- Parameters
1608
- ----------
1609
- variant_id : str
1610
-
1611
- request_options : typing.Optional[RequestOptions]
1612
- Request-specific configuration.
1613
-
1614
- Returns
1615
- -------
1616
- typing.Optional[typing.Any]
1617
- Successful Response
1618
-
1619
- Examples
1620
- --------
1621
- import asyncio
1622
-
1623
- from agenta import AsyncAgentaApi
1624
-
1625
- client = AsyncAgentaApi(
1626
- api_key="YOUR_API_KEY",
1627
- base_url="https://yourhost.com/path/to/api",
1628
- )
1629
-
1630
-
1631
- async def main() -> None:
1632
- await client.variants.remove_variant(
1633
- variant_id="variant_id",
1634
- )
1635
-
1636
-
1637
- asyncio.run(main())
1638
- """
1639
- _response = await self._client_wrapper.httpx_client.request(
1640
- f"variants/{jsonable_encoder(variant_id)}",
1641
- method="DELETE",
1642
- request_options=request_options,
1643
- )
1644
- try:
1645
- if 200 <= _response.status_code < 300:
1646
- return typing.cast(
1647
- typing.Optional[typing.Any],
1648
- parse_obj_as(
1649
- type_=typing.Optional[typing.Any], # type: ignore
1650
- object_=_response.json(),
1651
- ),
1652
- )
1653
- if _response.status_code == 422:
1654
- raise UnprocessableEntityError(
1655
- typing.cast(
1656
- HttpValidationError,
1657
- parse_obj_as(
1658
- type_=HttpValidationError, # type: ignore
1659
- object_=_response.json(),
1660
- ),
1661
- )
1662
- )
1663
- _response_json = _response.json()
1664
- except JSONDecodeError:
1665
- raise ApiError(status_code=_response.status_code, body=_response.text)
1666
- raise ApiError(status_code=_response.status_code, body=_response_json)
1667
-
1668
- async def update_variant_parameters(
1669
- self,
1670
- variant_id: str,
1671
- *,
1672
- parameters: typing.Dict[str, typing.Optional[typing.Any]],
1673
- request_options: typing.Optional[RequestOptions] = None,
1674
- ) -> typing.Optional[typing.Any]:
1675
- """
1676
- Updates the parameters for an app variant.
1677
-
1678
- Args:
1679
- variant_id (str): The ID of the app variant to update.
1680
- payload (UpdateVariantParameterPayload): The payload containing the updated parameters.
1681
- stoken_session (SessionContainer, optional): The session container. Defaults to Depends(verify_session()).
1682
-
1683
- Raises:
1684
- HTTPException: If there is an error while trying to update the app variant.
1685
-
1686
- Returns:
1687
- JSONResponse: A JSON response containing the updated app variant parameters.
1688
-
1689
- Parameters
1690
- ----------
1691
- variant_id : str
1692
-
1693
- parameters : typing.Dict[str, typing.Optional[typing.Any]]
1694
-
1695
- request_options : typing.Optional[RequestOptions]
1696
- Request-specific configuration.
1697
-
1698
- Returns
1699
- -------
1700
- typing.Optional[typing.Any]
1701
- Successful Response
1702
-
1703
- Examples
1704
- --------
1705
- import asyncio
1706
-
1707
- from agenta import AsyncAgentaApi
1708
-
1709
- client = AsyncAgentaApi(
1710
- api_key="YOUR_API_KEY",
1711
- base_url="https://yourhost.com/path/to/api",
1712
- )
1713
-
1714
-
1715
- async def main() -> None:
1716
- await client.variants.update_variant_parameters(
1717
- variant_id="variant_id",
1718
- parameters={"key": "value"},
1719
- )
1720
-
1721
-
1722
- asyncio.run(main())
1723
- """
1724
- _response = await self._client_wrapper.httpx_client.request(
1725
- f"variants/{jsonable_encoder(variant_id)}/parameters",
1726
- method="PUT",
1727
- json={
1728
- "parameters": parameters,
1729
- },
1730
- request_options=request_options,
1731
- omit=OMIT,
1732
- )
1733
- try:
1734
- if 200 <= _response.status_code < 300:
1735
- return typing.cast(
1736
- typing.Optional[typing.Any],
1737
- parse_obj_as(
1738
- type_=typing.Optional[typing.Any], # type: ignore
1739
- object_=_response.json(),
1740
- ),
1741
- )
1742
- if _response.status_code == 422:
1743
- raise UnprocessableEntityError(
1744
- typing.cast(
1745
- HttpValidationError,
1746
- parse_obj_as(
1747
- type_=HttpValidationError, # type: ignore
1748
- object_=_response.json(),
1749
- ),
1750
- )
1751
- )
1752
- _response_json = _response.json()
1753
- except JSONDecodeError:
1754
- raise ApiError(status_code=_response.status_code, body=_response.text)
1755
- raise ApiError(status_code=_response.status_code, body=_response_json)
1756
-
1757
- async def update_variant_image(
1758
- self,
1759
- variant_id: str,
1760
- *,
1761
- docker_id: str,
1762
- tags: str,
1763
- type: typing.Optional[str] = OMIT,
1764
- organization_id: typing.Optional[str] = OMIT,
1765
- workspace_id: typing.Optional[str] = OMIT,
1766
- request_options: typing.Optional[RequestOptions] = None,
1767
- ) -> typing.Optional[typing.Any]:
1768
- """
1769
- Updates the image used in an app variant.
1770
-
1771
- Args:
1772
- variant_id (str): The ID of the app variant to update.
1773
- image (Image): The image information to update.
1774
-
1775
- Raises:
1776
- HTTPException: If an error occurs while trying to update the app variant.
1777
-
1778
- Returns:
1779
- JSONResponse: A JSON response indicating whether the update was successful or not.
1780
-
1781
- Parameters
1782
- ----------
1783
- variant_id : str
1784
-
1785
- docker_id : str
1786
-
1787
- tags : str
1788
-
1789
- type : typing.Optional[str]
1790
-
1791
- organization_id : typing.Optional[str]
1792
-
1793
- workspace_id : typing.Optional[str]
1794
-
1795
- request_options : typing.Optional[RequestOptions]
1796
- Request-specific configuration.
1797
-
1798
- Returns
1799
- -------
1800
- typing.Optional[typing.Any]
1801
- Successful Response
1802
-
1803
- Examples
1804
- --------
1805
- import asyncio
1806
-
1807
- from agenta import AsyncAgentaApi
1808
-
1809
- client = AsyncAgentaApi(
1810
- api_key="YOUR_API_KEY",
1811
- base_url="https://yourhost.com/path/to/api",
1812
- )
1813
-
1814
-
1815
- async def main() -> None:
1816
- await client.variants.update_variant_image(
1817
- variant_id="variant_id",
1818
- docker_id="docker_id",
1819
- tags="tags",
1820
- )
1821
-
1822
-
1823
- asyncio.run(main())
1824
- """
1825
- _response = await self._client_wrapper.httpx_client.request(
1826
- f"variants/{jsonable_encoder(variant_id)}/image",
1827
- method="PUT",
1828
- json={
1829
- "type": type,
1830
- "docker_id": docker_id,
1831
- "tags": tags,
1832
- "organization_id": organization_id,
1833
- "workspace_id": workspace_id,
1834
- },
1835
- request_options=request_options,
1836
- omit=OMIT,
1837
- )
1838
- try:
1839
- if 200 <= _response.status_code < 300:
1840
- return typing.cast(
1841
- typing.Optional[typing.Any],
1842
- parse_obj_as(
1843
- type_=typing.Optional[typing.Any], # type: ignore
1844
- object_=_response.json(),
1845
- ),
1846
- )
1847
- if _response.status_code == 422:
1848
- raise UnprocessableEntityError(
1849
- typing.cast(
1850
- HttpValidationError,
1851
- parse_obj_as(
1852
- type_=HttpValidationError, # type: ignore
1853
- object_=_response.json(),
1854
- ),
1855
- )
1856
- )
1857
- _response_json = _response.json()
1858
- except JSONDecodeError:
1859
- raise ApiError(status_code=_response.status_code, body=_response.text)
1860
- raise ApiError(status_code=_response.status_code, body=_response_json)
1861
-
1862
- async def retrieve_variant_logs(
1863
- self,
1864
- variant_id: str,
1865
- *,
1866
- request_options: typing.Optional[RequestOptions] = None,
1867
- ) -> typing.Optional[typing.Any]:
1868
- """
1869
- Parameters
1870
- ----------
1871
- variant_id : str
1872
-
1873
- request_options : typing.Optional[RequestOptions]
1874
- Request-specific configuration.
1875
-
1876
- Returns
1877
- -------
1878
- typing.Optional[typing.Any]
1879
- Successful Response
1880
-
1881
- Examples
1882
- --------
1883
- import asyncio
1884
-
1885
- from agenta import AsyncAgentaApi
1886
-
1887
- client = AsyncAgentaApi(
1888
- api_key="YOUR_API_KEY",
1889
- base_url="https://yourhost.com/path/to/api",
1890
- )
1891
-
1892
-
1893
- async def main() -> None:
1894
- await client.variants.retrieve_variant_logs(
1895
- variant_id="variant_id",
1896
- )
1897
-
1898
-
1899
- asyncio.run(main())
1900
- """
1901
- _response = await self._client_wrapper.httpx_client.request(
1902
- f"variants/{jsonable_encoder(variant_id)}/logs",
1903
- method="GET",
1904
- request_options=request_options,
1905
- )
1906
- try:
1907
- if 200 <= _response.status_code < 300:
1908
- return typing.cast(
1909
- typing.Optional[typing.Any],
1910
- parse_obj_as(
1911
- type_=typing.Optional[typing.Any], # type: ignore
1912
- object_=_response.json(),
1913
- ),
1914
- )
1915
- if _response.status_code == 422:
1916
- raise UnprocessableEntityError(
1917
- typing.cast(
1918
- HttpValidationError,
1919
- parse_obj_as(
1920
- type_=HttpValidationError, # type: ignore
1921
- object_=_response.json(),
1922
- ),
1923
- )
1924
- )
1925
- _response_json = _response.json()
1926
- except JSONDecodeError:
1927
- raise ApiError(status_code=_response.status_code, body=_response.text)
1928
- raise ApiError(status_code=_response.status_code, body=_response_json)
1929
-
1930
- async def get_variant_revisions(
1931
- self,
1932
- variant_id: str,
1933
- *,
1934
- request_options: typing.Optional[RequestOptions] = None,
1935
- ) -> typing.List[AppVariantRevision]:
1936
- """
1937
- Parameters
1938
- ----------
1939
- variant_id : str
1940
-
1941
- request_options : typing.Optional[RequestOptions]
1942
- Request-specific configuration.
1943
-
1944
- Returns
1945
- -------
1946
- typing.List[AppVariantRevision]
1947
- Successful Response
1948
-
1949
- Examples
1950
- --------
1951
- import asyncio
1952
-
1953
- from agenta import AsyncAgentaApi
1954
-
1955
- client = AsyncAgentaApi(
1956
- api_key="YOUR_API_KEY",
1957
- base_url="https://yourhost.com/path/to/api",
1958
- )
1959
-
1960
-
1961
- async def main() -> None:
1962
- await client.variants.get_variant_revisions(
1963
- variant_id="variant_id",
1964
- )
1965
-
1966
-
1967
- asyncio.run(main())
1968
- """
1969
- _response = await self._client_wrapper.httpx_client.request(
1970
- f"variants/{jsonable_encoder(variant_id)}/revisions",
1971
- method="GET",
1972
- request_options=request_options,
1973
- )
1974
- try:
1975
- if 200 <= _response.status_code < 300:
1976
- return typing.cast(
1977
- typing.List[AppVariantRevision],
1978
- parse_obj_as(
1979
- type_=typing.List[AppVariantRevision], # type: ignore
1980
- object_=_response.json(),
1981
- ),
1982
- )
1983
- if _response.status_code == 422:
1984
- raise UnprocessableEntityError(
1985
- typing.cast(
1986
- HttpValidationError,
1987
- parse_obj_as(
1988
- type_=HttpValidationError, # type: ignore
1989
- object_=_response.json(),
1990
- ),
1991
- )
1992
- )
1993
- _response_json = _response.json()
1994
- except JSONDecodeError:
1995
- raise ApiError(status_code=_response.status_code, body=_response.text)
1996
- raise ApiError(status_code=_response.status_code, body=_response_json)
1997
-
1998
- async def get_variant_revision(
1999
- self,
2000
- variant_id: str,
2001
- revision_number: int,
2002
- *,
2003
- request_options: typing.Optional[RequestOptions] = None,
2004
- ) -> AppVariantRevision:
2005
- """
2006
- Parameters
2007
- ----------
2008
- variant_id : str
2009
-
2010
- revision_number : int
2011
-
2012
- request_options : typing.Optional[RequestOptions]
2013
- Request-specific configuration.
2014
-
2015
- Returns
2016
- -------
2017
- AppVariantRevision
2018
- Successful Response
2019
-
2020
- Examples
2021
- --------
2022
- import asyncio
2023
-
2024
- from agenta import AsyncAgentaApi
2025
-
2026
- client = AsyncAgentaApi(
2027
- api_key="YOUR_API_KEY",
2028
- base_url="https://yourhost.com/path/to/api",
2029
- )
2030
-
2031
-
2032
- async def main() -> None:
2033
- await client.variants.get_variant_revision(
2034
- variant_id="variant_id",
2035
- revision_number=1,
2036
- )
2037
-
2038
-
2039
- asyncio.run(main())
2040
- """
2041
- _response = await self._client_wrapper.httpx_client.request(
2042
- f"variants/{jsonable_encoder(variant_id)}/revisions/{jsonable_encoder(revision_number)}",
2043
- method="GET",
2044
- request_options=request_options,
2045
- )
2046
- try:
2047
- if 200 <= _response.status_code < 300:
2048
- return typing.cast(
2049
- AppVariantRevision,
2050
- parse_obj_as(
2051
- type_=AppVariantRevision, # type: ignore
2052
- object_=_response.json(),
2053
- ),
2054
- )
2055
- if _response.status_code == 422:
2056
- raise UnprocessableEntityError(
2057
- typing.cast(
2058
- HttpValidationError,
2059
- parse_obj_as(
2060
- type_=HttpValidationError, # type: ignore
2061
- object_=_response.json(),
2062
- ),
2063
- )
2064
- )
2065
- _response_json = _response.json()
2066
- except JSONDecodeError:
2067
- raise ApiError(status_code=_response.status_code, body=_response.text)
2068
- raise ApiError(status_code=_response.status_code, body=_response_json)
2069
-
2070
- async def configs_add(
2071
- self,
2072
- *,
2073
- variant_ref: ReferenceRequestModel,
2074
- application_ref: ReferenceRequestModel,
2075
- request_options: typing.Optional[RequestOptions] = None,
2076
- ) -> ConfigResponseModel:
2077
- """
2078
- Parameters
2079
- ----------
2080
- variant_ref : ReferenceRequestModel
2081
-
2082
- application_ref : ReferenceRequestModel
2083
-
2084
- request_options : typing.Optional[RequestOptions]
2085
- Request-specific configuration.
2086
-
2087
- Returns
2088
- -------
2089
- ConfigResponseModel
2090
- Successful Response
2091
-
2092
- Examples
2093
- --------
2094
- import asyncio
2095
-
2096
- from agenta import AsyncAgentaApi, ReferenceRequestModel
2097
-
2098
- client = AsyncAgentaApi(
2099
- api_key="YOUR_API_KEY",
2100
- base_url="https://yourhost.com/path/to/api",
2101
- )
2102
-
2103
-
2104
- async def main() -> None:
2105
- await client.variants.configs_add(
2106
- variant_ref=ReferenceRequestModel(),
2107
- application_ref=ReferenceRequestModel(),
2108
- )
2109
-
2110
-
2111
- asyncio.run(main())
2112
- """
2113
- _response = await self._client_wrapper.httpx_client.request(
2114
- "variants/configs/add",
2115
- method="POST",
2116
- json={
2117
- "variant_ref": convert_and_respect_annotation_metadata(
2118
- object_=variant_ref,
2119
- annotation=ReferenceRequestModel,
2120
- direction="write",
2121
- ),
2122
- "application_ref": convert_and_respect_annotation_metadata(
2123
- object_=application_ref,
2124
- annotation=ReferenceRequestModel,
2125
- direction="write",
2126
- ),
2127
- },
2128
- request_options=request_options,
2129
- omit=OMIT,
2130
- )
2131
- try:
2132
- if 200 <= _response.status_code < 300:
2133
- return typing.cast(
2134
- ConfigResponseModel,
2135
- parse_obj_as(
2136
- type_=ConfigResponseModel, # type: ignore
2137
- object_=_response.json(),
2138
- ),
2139
- )
2140
- if _response.status_code == 422:
2141
- raise UnprocessableEntityError(
2142
- typing.cast(
2143
- HttpValidationError,
2144
- parse_obj_as(
2145
- type_=HttpValidationError, # type: ignore
2146
- object_=_response.json(),
2147
- ),
2148
- )
2149
- )
2150
- _response_json = _response.json()
2151
- except JSONDecodeError:
2152
- raise ApiError(status_code=_response.status_code, body=_response.text)
2153
- raise ApiError(status_code=_response.status_code, body=_response_json)
2154
-
2155
- async def configs_fetch(
2156
- self,
2157
- *,
2158
- variant_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2159
- environment_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2160
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2161
- request_options: typing.Optional[RequestOptions] = None,
2162
- ) -> ConfigResponseModel:
2163
- """
2164
- Parameters
2165
- ----------
2166
- variant_ref : typing.Optional[ReferenceRequestModel]
2167
-
2168
- environment_ref : typing.Optional[ReferenceRequestModel]
2169
-
2170
- application_ref : typing.Optional[ReferenceRequestModel]
2171
-
2172
- request_options : typing.Optional[RequestOptions]
2173
- Request-specific configuration.
2174
-
2175
- Returns
2176
- -------
2177
- ConfigResponseModel
2178
- Successful Response
2179
-
2180
- Examples
2181
- --------
2182
- import asyncio
2183
-
2184
- from agenta import AsyncAgentaApi
2185
-
2186
- client = AsyncAgentaApi(
2187
- api_key="YOUR_API_KEY",
2188
- base_url="https://yourhost.com/path/to/api",
2189
- )
2190
-
2191
-
2192
- async def main() -> None:
2193
- await client.variants.configs_fetch()
2194
-
2195
-
2196
- asyncio.run(main())
2197
- """
2198
- _response = await self._client_wrapper.httpx_client.request(
2199
- "variants/configs/fetch",
2200
- method="POST",
2201
- json={
2202
- "variant_ref": convert_and_respect_annotation_metadata(
2203
- object_=variant_ref,
2204
- annotation=ReferenceRequestModel,
2205
- direction="write",
2206
- ),
2207
- "environment_ref": convert_and_respect_annotation_metadata(
2208
- object_=environment_ref,
2209
- annotation=ReferenceRequestModel,
2210
- direction="write",
2211
- ),
2212
- "application_ref": convert_and_respect_annotation_metadata(
2213
- object_=application_ref,
2214
- annotation=ReferenceRequestModel,
2215
- direction="write",
2216
- ),
2217
- },
2218
- request_options=request_options,
2219
- omit=OMIT,
2220
- )
2221
- try:
2222
- if 200 <= _response.status_code < 300:
2223
- return typing.cast(
2224
- ConfigResponseModel,
2225
- parse_obj_as(
2226
- type_=ConfigResponseModel, # type: ignore
2227
- object_=_response.json(),
2228
- ),
2229
- )
2230
- if _response.status_code == 422:
2231
- raise UnprocessableEntityError(
2232
- typing.cast(
2233
- HttpValidationError,
2234
- parse_obj_as(
2235
- type_=HttpValidationError, # type: ignore
2236
- object_=_response.json(),
2237
- ),
2238
- )
2239
- )
2240
- _response_json = _response.json()
2241
- except JSONDecodeError:
2242
- raise ApiError(status_code=_response.status_code, body=_response.text)
2243
- raise ApiError(status_code=_response.status_code, body=_response_json)
1157
+ Returns:
1158
+ JSONResponse: A JSON response indicating whether the update was successful or not.
2244
1159
 
2245
- async def configs_fork(
2246
- self,
2247
- *,
2248
- variant_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2249
- environment_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2250
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2251
- request_options: typing.Optional[RequestOptions] = None,
2252
- ) -> ConfigResponseModel:
2253
- """
2254
1160
  Parameters
2255
1161
  ----------
2256
- variant_ref : typing.Optional[ReferenceRequestModel]
2257
-
2258
- environment_ref : typing.Optional[ReferenceRequestModel]
2259
-
2260
- application_ref : typing.Optional[ReferenceRequestModel]
2261
-
2262
- request_options : typing.Optional[RequestOptions]
2263
- Request-specific configuration.
2264
-
2265
- Returns
2266
- -------
2267
- ConfigResponseModel
2268
- Successful Response
2269
-
2270
- Examples
2271
- --------
2272
- import asyncio
2273
-
2274
- from agenta import AsyncAgentaApi
2275
-
2276
- client = AsyncAgentaApi(
2277
- api_key="YOUR_API_KEY",
2278
- base_url="https://yourhost.com/path/to/api",
2279
- )
1162
+ variant_id : str
2280
1163
 
1164
+ docker_id : str
2281
1165
 
2282
- async def main() -> None:
2283
- await client.variants.configs_fork()
1166
+ tags : str
2284
1167
 
1168
+ type : typing.Optional[str]
2285
1169
 
2286
- asyncio.run(main())
2287
- """
2288
- _response = await self._client_wrapper.httpx_client.request(
2289
- "variants/configs/fork",
2290
- method="POST",
2291
- json={
2292
- "variant_ref": convert_and_respect_annotation_metadata(
2293
- object_=variant_ref,
2294
- annotation=ReferenceRequestModel,
2295
- direction="write",
2296
- ),
2297
- "environment_ref": convert_and_respect_annotation_metadata(
2298
- object_=environment_ref,
2299
- annotation=ReferenceRequestModel,
2300
- direction="write",
2301
- ),
2302
- "application_ref": convert_and_respect_annotation_metadata(
2303
- object_=application_ref,
2304
- annotation=ReferenceRequestModel,
2305
- direction="write",
2306
- ),
2307
- },
2308
- request_options=request_options,
2309
- omit=OMIT,
2310
- )
2311
- try:
2312
- if 200 <= _response.status_code < 300:
2313
- return typing.cast(
2314
- ConfigResponseModel,
2315
- parse_obj_as(
2316
- type_=ConfigResponseModel, # type: ignore
2317
- object_=_response.json(),
2318
- ),
2319
- )
2320
- if _response.status_code == 422:
2321
- raise UnprocessableEntityError(
2322
- typing.cast(
2323
- HttpValidationError,
2324
- parse_obj_as(
2325
- type_=HttpValidationError, # type: ignore
2326
- object_=_response.json(),
2327
- ),
2328
- )
2329
- )
2330
- _response_json = _response.json()
2331
- except JSONDecodeError:
2332
- raise ApiError(status_code=_response.status_code, body=_response.text)
2333
- raise ApiError(status_code=_response.status_code, body=_response_json)
1170
+ organization_id : typing.Optional[str]
2334
1171
 
2335
- async def configs_commit(
2336
- self,
2337
- *,
2338
- config: ConfigDto,
2339
- request_options: typing.Optional[RequestOptions] = None,
2340
- ) -> ConfigResponseModel:
2341
- """
2342
- Parameters
2343
- ----------
2344
- config : ConfigDto
1172
+ workspace_id : typing.Optional[str]
2345
1173
 
2346
1174
  request_options : typing.Optional[RequestOptions]
2347
1175
  Request-specific configuration.
2348
1176
 
2349
1177
  Returns
2350
1178
  -------
2351
- ConfigResponseModel
1179
+ typing.Optional[typing.Any]
2352
1180
  Successful Response
2353
1181
 
2354
1182
  Examples
2355
1183
  --------
2356
1184
  import asyncio
2357
1185
 
2358
- from agenta import AsyncAgentaApi, ConfigDto
1186
+ from agenta import AsyncAgentaApi
2359
1187
 
2360
1188
  client = AsyncAgentaApi(
2361
1189
  api_key="YOUR_API_KEY",
@@ -2364,22 +1192,24 @@ class AsyncVariantsClient:
2364
1192
 
2365
1193
 
2366
1194
  async def main() -> None:
2367
- await client.variants.configs_commit(
2368
- config=ConfigDto(
2369
- params={"key": "value"},
2370
- ),
1195
+ await client.variants.update_variant_image(
1196
+ variant_id="variant_id",
1197
+ docker_id="docker_id",
1198
+ tags="tags",
2371
1199
  )
2372
1200
 
2373
1201
 
2374
1202
  asyncio.run(main())
2375
1203
  """
2376
1204
  _response = await self._client_wrapper.httpx_client.request(
2377
- "variants/configs/commit",
2378
- method="POST",
1205
+ f"variants/{jsonable_encoder(variant_id)}/image",
1206
+ method="PUT",
2379
1207
  json={
2380
- "config": convert_and_respect_annotation_metadata(
2381
- object_=config, annotation=ConfigDto, direction="write"
2382
- ),
1208
+ "type": type,
1209
+ "docker_id": docker_id,
1210
+ "tags": tags,
1211
+ "organization_id": organization_id,
1212
+ "workspace_id": workspace_id,
2383
1213
  },
2384
1214
  request_options=request_options,
2385
1215
  omit=OMIT,
@@ -2387,9 +1217,9 @@ class AsyncVariantsClient:
2387
1217
  try:
2388
1218
  if 200 <= _response.status_code < 300:
2389
1219
  return typing.cast(
2390
- ConfigResponseModel,
1220
+ typing.Optional[typing.Any],
2391
1221
  parse_obj_as(
2392
- type_=ConfigResponseModel, # type: ignore
1222
+ type_=typing.Optional[typing.Any], # type: ignore
2393
1223
  object_=_response.json(),
2394
1224
  ),
2395
1225
  )
@@ -2408,36 +1238,30 @@ class AsyncVariantsClient:
2408
1238
  raise ApiError(status_code=_response.status_code, body=_response.text)
2409
1239
  raise ApiError(status_code=_response.status_code, body=_response_json)
2410
1240
 
2411
- async def configs_deploy(
1241
+ async def retrieve_variant_logs(
2412
1242
  self,
1243
+ variant_id: str,
2413
1244
  *,
2414
- variant_ref: ReferenceRequestModel,
2415
- environment_ref: ReferenceRequestModel,
2416
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2417
1245
  request_options: typing.Optional[RequestOptions] = None,
2418
- ) -> ConfigResponseModel:
1246
+ ) -> typing.Optional[typing.Any]:
2419
1247
  """
2420
1248
  Parameters
2421
1249
  ----------
2422
- variant_ref : ReferenceRequestModel
2423
-
2424
- environment_ref : ReferenceRequestModel
2425
-
2426
- application_ref : typing.Optional[ReferenceRequestModel]
1250
+ variant_id : str
2427
1251
 
2428
1252
  request_options : typing.Optional[RequestOptions]
2429
1253
  Request-specific configuration.
2430
1254
 
2431
1255
  Returns
2432
1256
  -------
2433
- ConfigResponseModel
1257
+ typing.Optional[typing.Any]
2434
1258
  Successful Response
2435
1259
 
2436
1260
  Examples
2437
1261
  --------
2438
1262
  import asyncio
2439
1263
 
2440
- from agenta import AsyncAgentaApi, ReferenceRequestModel
1264
+ from agenta import AsyncAgentaApi
2441
1265
 
2442
1266
  client = AsyncAgentaApi(
2443
1267
  api_key="YOUR_API_KEY",
@@ -2446,43 +1270,24 @@ class AsyncVariantsClient:
2446
1270
 
2447
1271
 
2448
1272
  async def main() -> None:
2449
- await client.variants.configs_deploy(
2450
- variant_ref=ReferenceRequestModel(),
2451
- environment_ref=ReferenceRequestModel(),
1273
+ await client.variants.retrieve_variant_logs(
1274
+ variant_id="variant_id",
2452
1275
  )
2453
1276
 
2454
1277
 
2455
1278
  asyncio.run(main())
2456
1279
  """
2457
1280
  _response = await self._client_wrapper.httpx_client.request(
2458
- "variants/configs/deploy",
2459
- method="POST",
2460
- json={
2461
- "variant_ref": convert_and_respect_annotation_metadata(
2462
- object_=variant_ref,
2463
- annotation=ReferenceRequestModel,
2464
- direction="write",
2465
- ),
2466
- "environment_ref": convert_and_respect_annotation_metadata(
2467
- object_=environment_ref,
2468
- annotation=ReferenceRequestModel,
2469
- direction="write",
2470
- ),
2471
- "application_ref": convert_and_respect_annotation_metadata(
2472
- object_=application_ref,
2473
- annotation=ReferenceRequestModel,
2474
- direction="write",
2475
- ),
2476
- },
1281
+ f"variants/{jsonable_encoder(variant_id)}/logs",
1282
+ method="GET",
2477
1283
  request_options=request_options,
2478
- omit=OMIT,
2479
1284
  )
2480
1285
  try:
2481
1286
  if 200 <= _response.status_code < 300:
2482
1287
  return typing.cast(
2483
- ConfigResponseModel,
1288
+ typing.Optional[typing.Any],
2484
1289
  parse_obj_as(
2485
- type_=ConfigResponseModel, # type: ignore
1290
+ type_=typing.Optional[typing.Any], # type: ignore
2486
1291
  object_=_response.json(),
2487
1292
  ),
2488
1293
  )
@@ -2501,26 +1306,23 @@ class AsyncVariantsClient:
2501
1306
  raise ApiError(status_code=_response.status_code, body=_response.text)
2502
1307
  raise ApiError(status_code=_response.status_code, body=_response_json)
2503
1308
 
2504
- async def configs_delete(
1309
+ async def get_variant_revisions(
2505
1310
  self,
1311
+ variant_id: str,
2506
1312
  *,
2507
- variant_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2508
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2509
1313
  request_options: typing.Optional[RequestOptions] = None,
2510
- ) -> int:
1314
+ ) -> typing.List[AppVariantRevision]:
2511
1315
  """
2512
1316
  Parameters
2513
1317
  ----------
2514
- variant_ref : typing.Optional[ReferenceRequestModel]
2515
-
2516
- application_ref : typing.Optional[ReferenceRequestModel]
1318
+ variant_id : str
2517
1319
 
2518
1320
  request_options : typing.Optional[RequestOptions]
2519
1321
  Request-specific configuration.
2520
1322
 
2521
1323
  Returns
2522
1324
  -------
2523
- int
1325
+ typing.List[AppVariantRevision]
2524
1326
  Successful Response
2525
1327
 
2526
1328
  Examples
@@ -2536,109 +1338,24 @@ class AsyncVariantsClient:
2536
1338
 
2537
1339
 
2538
1340
  async def main() -> None:
2539
- await client.variants.configs_delete()
2540
-
2541
-
2542
- asyncio.run(main())
2543
- """
2544
- _response = await self._client_wrapper.httpx_client.request(
2545
- "variants/configs/delete",
2546
- method="POST",
2547
- json={
2548
- "variant_ref": convert_and_respect_annotation_metadata(
2549
- object_=variant_ref,
2550
- annotation=ReferenceRequestModel,
2551
- direction="write",
2552
- ),
2553
- "application_ref": convert_and_respect_annotation_metadata(
2554
- object_=application_ref,
2555
- annotation=ReferenceRequestModel,
2556
- direction="write",
2557
- ),
2558
- },
2559
- request_options=request_options,
2560
- omit=OMIT,
2561
- )
2562
- try:
2563
- if 200 <= _response.status_code < 300:
2564
- return typing.cast(
2565
- int,
2566
- parse_obj_as(
2567
- type_=int, # type: ignore
2568
- object_=_response.json(),
2569
- ),
2570
- )
2571
- if _response.status_code == 422:
2572
- raise UnprocessableEntityError(
2573
- typing.cast(
2574
- HttpValidationError,
2575
- parse_obj_as(
2576
- type_=HttpValidationError, # type: ignore
2577
- object_=_response.json(),
2578
- ),
2579
- )
2580
- )
2581
- _response_json = _response.json()
2582
- except JSONDecodeError:
2583
- raise ApiError(status_code=_response.status_code, body=_response.text)
2584
- raise ApiError(status_code=_response.status_code, body=_response_json)
2585
-
2586
- async def configs_list(
2587
- self,
2588
- *,
2589
- application_ref: ReferenceDto,
2590
- request_options: typing.Optional[RequestOptions] = None,
2591
- ) -> typing.List[ConfigResponseModel]:
2592
- """
2593
- Parameters
2594
- ----------
2595
- application_ref : ReferenceDto
2596
-
2597
- request_options : typing.Optional[RequestOptions]
2598
- Request-specific configuration.
2599
-
2600
- Returns
2601
- -------
2602
- typing.List[ConfigResponseModel]
2603
- Successful Response
2604
-
2605
- Examples
2606
- --------
2607
- import asyncio
2608
-
2609
- from agenta import AsyncAgentaApi, ReferenceDto
2610
-
2611
- client = AsyncAgentaApi(
2612
- api_key="YOUR_API_KEY",
2613
- base_url="https://yourhost.com/path/to/api",
2614
- )
2615
-
2616
-
2617
- async def main() -> None:
2618
- await client.variants.configs_list(
2619
- application_ref=ReferenceDto(),
1341
+ await client.variants.get_variant_revisions(
1342
+ variant_id="variant_id",
2620
1343
  )
2621
1344
 
2622
1345
 
2623
1346
  asyncio.run(main())
2624
1347
  """
2625
1348
  _response = await self._client_wrapper.httpx_client.request(
2626
- "variants/configs/list",
2627
- method="POST",
2628
- json={
2629
- "application_ref": convert_and_respect_annotation_metadata(
2630
- object_=application_ref, annotation=ReferenceDto, direction="write"
2631
- ),
2632
- },
1349
+ f"variants/{jsonable_encoder(variant_id)}/revisions",
1350
+ method="GET",
2633
1351
  request_options=request_options,
2634
- omit=OMIT,
2635
1352
  )
2636
1353
  try:
2637
1354
  if 200 <= _response.status_code < 300:
2638
1355
  return typing.cast(
2639
- typing.List[ConfigResponseModel],
1356
+ typing.List[AppVariantRevision],
2640
1357
  parse_obj_as(
2641
- type_=typing.List[ConfigResponseModel], # type: ignore
1358
+ type_=typing.List[AppVariantRevision], # type: ignore
2642
1359
  object_=_response.json(),
2643
1360
  ),
2644
1361
  )
@@ -2657,26 +1374,26 @@ class AsyncVariantsClient:
2657
1374
  raise ApiError(status_code=_response.status_code, body=_response.text)
2658
1375
  raise ApiError(status_code=_response.status_code, body=_response_json)
2659
1376
 
2660
- async def configs_history(
1377
+ async def get_variant_revision(
2661
1378
  self,
1379
+ variant_id: str,
1380
+ revision_number: int,
2662
1381
  *,
2663
- variant_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2664
- application_ref: typing.Optional[ReferenceRequestModel] = OMIT,
2665
1382
  request_options: typing.Optional[RequestOptions] = None,
2666
- ) -> typing.List[ConfigResponseModel]:
1383
+ ) -> AppVariantRevision:
2667
1384
  """
2668
1385
  Parameters
2669
1386
  ----------
2670
- variant_ref : typing.Optional[ReferenceRequestModel]
1387
+ variant_id : str
2671
1388
 
2672
- application_ref : typing.Optional[ReferenceRequestModel]
1389
+ revision_number : int
2673
1390
 
2674
1391
  request_options : typing.Optional[RequestOptions]
2675
1392
  Request-specific configuration.
2676
1393
 
2677
1394
  Returns
2678
1395
  -------
2679
- typing.List[ConfigResponseModel]
1396
+ AppVariantRevision
2680
1397
  Successful Response
2681
1398
 
2682
1399
  Examples
@@ -2692,35 +1409,25 @@ class AsyncVariantsClient:
2692
1409
 
2693
1410
 
2694
1411
  async def main() -> None:
2695
- await client.variants.configs_history()
1412
+ await client.variants.get_variant_revision(
1413
+ variant_id="variant_id",
1414
+ revision_number=1,
1415
+ )
2696
1416
 
2697
1417
 
2698
1418
  asyncio.run(main())
2699
1419
  """
2700
1420
  _response = await self._client_wrapper.httpx_client.request(
2701
- "variants/configs/history",
2702
- method="POST",
2703
- json={
2704
- "variant_ref": convert_and_respect_annotation_metadata(
2705
- object_=variant_ref,
2706
- annotation=ReferenceRequestModel,
2707
- direction="write",
2708
- ),
2709
- "application_ref": convert_and_respect_annotation_metadata(
2710
- object_=application_ref,
2711
- annotation=ReferenceRequestModel,
2712
- direction="write",
2713
- ),
2714
- },
1421
+ f"variants/{jsonable_encoder(variant_id)}/revisions/{jsonable_encoder(revision_number)}",
1422
+ method="GET",
2715
1423
  request_options=request_options,
2716
- omit=OMIT,
2717
1424
  )
2718
1425
  try:
2719
1426
  if 200 <= _response.status_code < 300:
2720
1427
  return typing.cast(
2721
- typing.List[ConfigResponseModel],
1428
+ AppVariantRevision,
2722
1429
  parse_obj_as(
2723
- type_=typing.List[ConfigResponseModel], # type: ignore
1430
+ type_=AppVariantRevision, # type: ignore
2724
1431
  object_=_response.json(),
2725
1432
  ),
2726
1433
  )