payi 0.1.0a115__tar.gz → 0.1.0a117__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.

Potentially problematic release.


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

Files changed (204) hide show
  1. payi-0.1.0a117/.release-please-manifest.json +3 -0
  2. {payi-0.1.0a115 → payi-0.1.0a117}/CHANGELOG.md +16 -0
  3. {payi-0.1.0a115 → payi-0.1.0a117}/PKG-INFO +1 -1
  4. {payi-0.1.0a115 → payi-0.1.0a117}/pyproject.toml +1 -2
  5. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_version.py +1 -1
  6. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/AnthropicInstrumentor.py +1 -1
  7. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/BedrockInstrumentor.py +137 -5
  8. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/instrument.py +34 -19
  9. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_client.py +6 -47
  10. payi-0.1.0a115/.release-please-manifest.json +0 -3
  11. {payi-0.1.0a115 → payi-0.1.0a117}/.gitignore +0 -0
  12. {payi-0.1.0a115 → payi-0.1.0a117}/CONTRIBUTING.md +0 -0
  13. {payi-0.1.0a115 → payi-0.1.0a117}/LICENSE +0 -0
  14. {payi-0.1.0a115 → payi-0.1.0a117}/README.md +0 -0
  15. {payi-0.1.0a115 → payi-0.1.0a117}/SECURITY.md +0 -0
  16. {payi-0.1.0a115 → payi-0.1.0a117}/api.md +0 -0
  17. {payi-0.1.0a115 → payi-0.1.0a117}/bin/check-release-environment +0 -0
  18. {payi-0.1.0a115 → payi-0.1.0a117}/bin/publish-pypi +0 -0
  19. {payi-0.1.0a115 → payi-0.1.0a117}/examples/.keep +0 -0
  20. {payi-0.1.0a115 → payi-0.1.0a117}/noxfile.py +0 -0
  21. {payi-0.1.0a115 → payi-0.1.0a117}/release-please-config.json +0 -0
  22. {payi-0.1.0a115 → payi-0.1.0a117}/requirements-dev.lock +0 -0
  23. {payi-0.1.0a115 → payi-0.1.0a117}/requirements.lock +0 -0
  24. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/__init__.py +0 -0
  25. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_base_client.py +0 -0
  26. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_client.py +0 -0
  27. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_compat.py +0 -0
  28. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_constants.py +0 -0
  29. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_exceptions.py +0 -0
  30. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_files.py +0 -0
  31. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_models.py +0 -0
  32. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_qs.py +0 -0
  33. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_resource.py +0 -0
  34. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_response.py +0 -0
  35. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_streaming.py +0 -0
  36. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_types.py +0 -0
  37. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/__init__.py +0 -0
  38. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_compat.py +0 -0
  39. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_datetime_parse.py +0 -0
  40. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_logs.py +0 -0
  41. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_proxy.py +0 -0
  42. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_reflection.py +0 -0
  43. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_resources_proxy.py +0 -0
  44. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_streams.py +0 -0
  45. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_sync.py +0 -0
  46. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_transform.py +0 -0
  47. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_typing.py +0 -0
  48. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/_utils/_utils.py +0 -0
  49. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/.keep +0 -0
  50. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/GoogleGenAiInstrumentor.py +0 -0
  51. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/OpenAIInstrumentor.py +0 -0
  52. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/Stopwatch.py +0 -0
  53. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/VertexInstrumentor.py +0 -0
  54. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/VertexRequest.py +0 -0
  55. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/data/cohere_embed_english_v3.json +0 -0
  56. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/helpers.py +0 -0
  57. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/lib/version_helper.py +0 -0
  58. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/pagination.py +0 -0
  59. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/py.typed +0 -0
  60. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/__init__.py +0 -0
  61. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/categories/__init__.py +0 -0
  62. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/categories/categories.py +0 -0
  63. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/categories/fixed_cost_resources.py +0 -0
  64. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/categories/resources.py +0 -0
  65. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/ingest.py +0 -0
  66. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/limits/__init__.py +0 -0
  67. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/limits/limits.py +0 -0
  68. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/limits/tags.py +0 -0
  69. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/__init__.py +0 -0
  70. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/request_id/__init__.py +0 -0
  71. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/request_id/properties.py +0 -0
  72. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/request_id/request_id.py +0 -0
  73. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/request_id/result.py +0 -0
  74. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/requests.py +0 -0
  75. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/response_id/__init__.py +0 -0
  76. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/response_id/properties.py +0 -0
  77. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/response_id/response_id.py +0 -0
  78. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/requests/response_id/result.py +0 -0
  79. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/__init__.py +0 -0
  80. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/definitions/__init__.py +0 -0
  81. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/definitions/definitions.py +0 -0
  82. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/definitions/kpis.py +0 -0
  83. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/definitions/limit_config.py +0 -0
  84. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/definitions/version.py +0 -0
  85. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/kpis.py +0 -0
  86. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/properties.py +0 -0
  87. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/resources/use_cases/use_cases.py +0 -0
  88. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/__init__.py +0 -0
  89. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/bulk_ingest_response.py +0 -0
  90. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/categories/__init__.py +0 -0
  91. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/categories/fixed_cost_resource_create_params.py +0 -0
  92. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/categories/resource_create_params.py +0 -0
  93. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/categories/resource_list_params.py +0 -0
  94. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/category_delete_resource_response.py +0 -0
  95. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/category_delete_response.py +0 -0
  96. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/category_list_params.py +0 -0
  97. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/category_list_resources_params.py +0 -0
  98. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/category_resource_response.py +0 -0
  99. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/category_response.py +0 -0
  100. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/cost_data.py +0 -0
  101. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/cost_details.py +0 -0
  102. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/default_response.py +0 -0
  103. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/ingest_bulk_params.py +0 -0
  104. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/ingest_event_param.py +0 -0
  105. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/ingest_response.py +0 -0
  106. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/ingest_units_params.py +0 -0
  107. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limit_create_params.py +0 -0
  108. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limit_history_response.py +0 -0
  109. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limit_list_params.py +0 -0
  110. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limit_list_response.py +0 -0
  111. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limit_reset_params.py +0 -0
  112. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limit_response.py +0 -0
  113. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limit_update_params.py +0 -0
  114. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/__init__.py +0 -0
  115. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/limit_tags.py +0 -0
  116. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/tag_create_params.py +0 -0
  117. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/tag_create_response.py +0 -0
  118. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/tag_delete_response.py +0 -0
  119. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/tag_list_response.py +0 -0
  120. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/tag_remove_params.py +0 -0
  121. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/tag_remove_response.py +0 -0
  122. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/tag_update_params.py +0 -0
  123. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/limits/tag_update_response.py +0 -0
  124. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/pay_i_common_models_api_router_header_info_param.py +0 -0
  125. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/request_result.py +0 -0
  126. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/requests/__init__.py +0 -0
  127. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/requests/request_id/__init__.py +0 -0
  128. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/requests/request_id/property_update_params.py +0 -0
  129. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/requests/response_id/__init__.py +0 -0
  130. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/requests/response_id/property_update_params.py +0 -0
  131. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/requests_data.py +0 -0
  132. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared/__init__.py +0 -0
  133. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared/evaluation_response.py +0 -0
  134. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared/ingest_units.py +0 -0
  135. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared/pay_i_common_models_budget_management_cost_details_base.py +0 -0
  136. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared/pay_i_common_models_budget_management_create_limit_base.py +0 -0
  137. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared/properties_response.py +0 -0
  138. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared/xproxy_error.py +0 -0
  139. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared/xproxy_result.py +0 -0
  140. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared_params/__init__.py +0 -0
  141. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared_params/ingest_units.py +0 -0
  142. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/shared_params/pay_i_common_models_budget_management_create_limit_base.py +0 -0
  143. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/total_cost_data.py +0 -0
  144. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_case_instance_response.py +0 -0
  145. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/__init__.py +0 -0
  146. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definition_create_params.py +0 -0
  147. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definition_list_params.py +0 -0
  148. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definition_update_params.py +0 -0
  149. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/__init__.py +0 -0
  150. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/kpi_create_params.py +0 -0
  151. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/kpi_create_response.py +0 -0
  152. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/kpi_delete_response.py +0 -0
  153. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/kpi_list_params.py +0 -0
  154. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/kpi_list_response.py +0 -0
  155. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/kpi_retrieve_response.py +0 -0
  156. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/kpi_update_params.py +0 -0
  157. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/kpi_update_response.py +0 -0
  158. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/definitions/limit_config_create_params.py +0 -0
  159. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/kpi_list_params.py +0 -0
  160. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/kpi_list_response.py +0 -0
  161. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/kpi_update_params.py +0 -0
  162. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/property_update_params.py +0 -0
  163. {payi-0.1.0a115 → payi-0.1.0a117}/src/payi/types/use_cases/use_case_definition.py +0 -0
  164. {payi-0.1.0a115 → payi-0.1.0a117}/tests/__init__.py +0 -0
  165. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/__init__.py +0 -0
  166. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/categories/__init__.py +0 -0
  167. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/categories/test_fixed_cost_resources.py +0 -0
  168. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/categories/test_resources.py +0 -0
  169. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/limits/__init__.py +0 -0
  170. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/limits/test_tags.py +0 -0
  171. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/requests/__init__.py +0 -0
  172. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/requests/request_id/__init__.py +0 -0
  173. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/requests/request_id/test_properties.py +0 -0
  174. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/requests/request_id/test_result.py +0 -0
  175. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/requests/response_id/__init__.py +0 -0
  176. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/requests/response_id/test_properties.py +0 -0
  177. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/requests/response_id/test_result.py +0 -0
  178. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/test_categories.py +0 -0
  179. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/test_ingest.py +0 -0
  180. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/test_limits.py +0 -0
  181. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/test_use_cases.py +0 -0
  182. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/use_cases/__init__.py +0 -0
  183. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/use_cases/definitions/__init__.py +0 -0
  184. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/use_cases/definitions/test_kpis.py +0 -0
  185. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/use_cases/definitions/test_limit_config.py +0 -0
  186. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/use_cases/definitions/test_version.py +0 -0
  187. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/use_cases/test_definitions.py +0 -0
  188. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/use_cases/test_kpis.py +0 -0
  189. {payi-0.1.0a115 → payi-0.1.0a117}/tests/api_resources/use_cases/test_properties.py +0 -0
  190. {payi-0.1.0a115 → payi-0.1.0a117}/tests/conftest.py +0 -0
  191. {payi-0.1.0a115 → payi-0.1.0a117}/tests/sample_file.txt +0 -0
  192. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_deepcopy.py +0 -0
  193. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_extract_files.py +0 -0
  194. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_files.py +0 -0
  195. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_models.py +0 -0
  196. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_qs.py +0 -0
  197. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_required_args.py +0 -0
  198. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_response.py +0 -0
  199. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_streaming.py +0 -0
  200. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_transform.py +0 -0
  201. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_utils/test_datetime_parse.py +0 -0
  202. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_utils/test_proxy.py +0 -0
  203. {payi-0.1.0a115 → payi-0.1.0a117}/tests/test_utils/test_typing.py +0 -0
  204. {payi-0.1.0a115 → payi-0.1.0a117}/tests/utils.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.1.0-alpha.117"
3
+ }
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0-alpha.117 (2025-09-16)
4
+
5
+ Full Changelog: [v0.1.0-alpha.116...v0.1.0-alpha.117](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.116...v0.1.0-alpha.117)
6
+
7
+ ### Chores
8
+
9
+ * **tests:** simplify `get_platform` test ([9aeaba6](https://github.com/Pay-i/pay-i-python/commit/9aeaba6c83b4cdcd6bb348609a9e22ad86b14b7a))
10
+
11
+ ## 0.1.0-alpha.116 (2025-09-06)
12
+
13
+ Full Changelog: [v0.1.0-alpha.115...v0.1.0-alpha.116](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.115...v0.1.0-alpha.116)
14
+
15
+ ### Features
16
+
17
+ * aws bedrock guardians ([#363](https://github.com/Pay-i/pay-i-python/issues/363)) ([08d74c8](https://github.com/Pay-i/pay-i-python/commit/08d74c8d49368cc0e8ae0b8d0f9a94458e7be0fa))
18
+
3
19
  ## 0.1.0-alpha.115 (2025-09-05)
4
20
 
5
21
  Full Changelog: [v0.1.0-alpha.114...v0.1.0-alpha.115](https://github.com/Pay-i/pay-i-python/compare/v0.1.0-alpha.114...v0.1.0-alpha.115)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: payi
3
- Version: 0.1.0a115
3
+ Version: 0.1.0a117
4
4
  Summary: The official Python library for the payi API
5
5
  Project-URL: Homepage, https://github.com/Pay-i/pay-i-python
6
6
  Project-URL: Repository, https://github.com/Pay-i/pay-i-python
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "payi"
3
- version = "0.1.0-alpha.115"
3
+ version = "0.1.0-alpha.117"
4
4
  description = "The official Python library for the payi API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -60,7 +60,6 @@ dev-dependencies = [
60
60
  "dirty-equals>=0.6.0",
61
61
  "importlib-metadata>=6.7.0",
62
62
  "rich>=13.7.1",
63
- "nest_asyncio==1.6.0",
64
63
  "pytest-xdist>=3.6.1",
65
64
  "wrapt",
66
65
  ]
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "payi"
4
- __version__ = "0.1.0-alpha.115" # x-release-please-version
4
+ __version__ = "0.1.0-alpha.117" # x-release-please-version
@@ -253,7 +253,7 @@ def anthropic_process_compute_input_cost(request: _ProviderRequest, usage: 'dict
253
253
 
254
254
  total_input_tokens = input + cache_creation_input_tokens + cache_read_input_tokens
255
255
 
256
- request._is_large_context = total_input_tokens > 200000
256
+ request._is_large_context = total_input_tokens >= 200000
257
257
  large_context = "_large_context" if request._is_large_context else ""
258
258
 
259
259
  cache_creation: dict[str, int] = usage.get("cache_creation", {})
@@ -11,9 +11,21 @@ from payi.lib.helpers import PayiCategories, PayiHeaderNames, payi_aws_bedrock_u
11
11
  from payi.types.ingest_units_params import Units
12
12
  from payi.types.pay_i_common_models_api_router_header_info_param import PayICommonModelsAPIRouterHeaderInfoParam
13
13
 
14
- from .instrument import _ChunkResult, _IsStreaming, _StreamingType, _ProviderRequest, _PayiInstrumentor
14
+ from .instrument import (
15
+ PayiInstrumentAwsBedrockConfig,
16
+ _ChunkResult,
17
+ _IsStreaming,
18
+ _StreamingType,
19
+ _ProviderRequest,
20
+ _PayiInstrumentor,
21
+ )
15
22
  from .version_helper import get_version_helper
16
23
 
24
+ GUARDRAIL_ID = "system.aws.bedrock.guardrail.id"
25
+ GUARDRAIL_VERSION = "system.aws.bedrock.guardrail.version"
26
+ GUARDRAIL_ACTION = "system.aws.bedrock.guardrail.action"
27
+
28
+ GUARDRAIL_SEMANTIC_FAILURE_DESCRIPTION = "Bedrock Guardrails intervened"
17
29
 
18
30
  class BedrockInstrumentor:
19
31
  _module_name: str = "boto3"
@@ -21,8 +33,10 @@ class BedrockInstrumentor:
21
33
 
22
34
  _instrumentor: _PayiInstrumentor
23
35
 
36
+ _guardrail_trace: bool = True
37
+
24
38
  @staticmethod
25
- def instrument(instrumentor: _PayiInstrumentor) -> None:
39
+ def instrument(instrumentor: _PayiInstrumentor, aws_config: Optional[PayiInstrumentAwsBedrockConfig]) -> None:
26
40
  BedrockInstrumentor._instrumentor = instrumentor
27
41
 
28
42
  BedrockInstrumentor._module_version = get_version_helper(BedrockInstrumentor._module_name)
@@ -44,6 +58,9 @@ class BedrockInstrumentor:
44
58
  instrumentor._logger.debug(f"Error instrumenting bedrock: {e}")
45
59
  return
46
60
 
61
+ if aws_config:
62
+ BedrockInstrumentor._guardrail_trace = aws_config.get("guardrail_trace", True)
63
+
47
64
  @_PayiInstrumentor.payi_wrapper
48
65
  def create_client_wrapper(instrumentor: _PayiInstrumentor, wrapped: Any, instance: Any, *args: Any, **kwargs: Any) -> Any: # noqa: ARG001
49
66
  if kwargs.get("service_name") != "bedrock-runtime":
@@ -184,7 +201,12 @@ class InvokeResponseWrapper(ObjectProxy): # type: ignore
184
201
 
185
202
  if self._log_prompt_and_response:
186
203
  ingest["provider_response_json"] = data.decode('utf-8') # type: ignore
187
-
204
+
205
+ guardrails = response.get("amazon-bedrock-trace", {}).get("guardrail", {}).get("input", {})
206
+ self._request.process_guardrails(guardrails)
207
+
208
+ self._request.process_stop_action(response.get("amazon-bedrock-guardrailAction", ""))
209
+
188
210
  self._request._instrumentor._ingest_units(self._request)
189
211
 
190
212
  return data # type: ignore
@@ -257,6 +279,7 @@ def wrap_converse_stream(instrumentor: _PayiInstrumentor, wrapped: Any) -> Any:
257
279
  return invoke_wrapper
258
280
 
259
281
  class _BedrockProviderRequest(_ProviderRequest):
282
+
260
283
  def __init__(self, instrumentor: _PayiInstrumentor):
261
284
  super().__init__(
262
285
  instrumentor=instrumentor,
@@ -303,6 +326,51 @@ class _BedrockProviderRequest(_ProviderRequest):
303
326
  self._instrumentor._logger.debug(f"Error processing exception: {e}")
304
327
  return False
305
328
 
329
+ def process_guardrails(self, guardrails: 'dict[str, Any]') -> None:
330
+ units = self._ingest["units"]
331
+
332
+ # while we iterate over the entire dict, only one guardrail is expected and supported
333
+ for _, value in guardrails.items():
334
+ # _ (key) is the guardrail id
335
+ if not isinstance(value, dict):
336
+ continue
337
+
338
+ usage: dict[str, int] = value.get("invocationMetrics", {}).get("usage", {}) # type: ignore
339
+ if not usage:
340
+ continue
341
+
342
+ topicPolicyUnits: int = usage.get("topicPolicyUnits", 0) # type: ignore
343
+ if topicPolicyUnits > 0:
344
+ units["guardrail_topic"] = Units(input=topicPolicyUnits, output=0) # type: ignore
345
+
346
+ contentPolicyUnits = usage.get("contentPolicyUnits", 0) # type: ignore
347
+ if contentPolicyUnits > 0:
348
+ units["guardrail_content"] = Units(input=contentPolicyUnits, output=0) # type: ignore
349
+
350
+ wordPolicyUnits = usage.get("wordPolicyUnits", 0) # type: ignore
351
+ if wordPolicyUnits > 0:
352
+ units["guardrail_word_free"] = Units(input=wordPolicyUnits, output=0) # type: ignore
353
+
354
+ automatedReasoningPolicyUnits = usage.get("automatedReasoningPolicyUnits", 0) # type: ignore
355
+ if automatedReasoningPolicyUnits > 0:
356
+ units["guardrail_automated_reasoning"] = Units(input=automatedReasoningPolicyUnits, output=0) # type: ignore
357
+
358
+ sensitiveInformationPolicyUnits = usage.get("sensitiveInformationPolicyUnits", 0) # type: ignore
359
+ if sensitiveInformationPolicyUnits > 0:
360
+ units["guardrail_sensitive_information"] = Units(input=sensitiveInformationPolicyUnits, output=0) # type: ignore
361
+
362
+ sensitiveInformationPolicyFreeUnits = usage.get("sensitiveInformationPolicyFreeUnits", 0) # type: ignore
363
+ if sensitiveInformationPolicyFreeUnits > 0:
364
+ units["guardrail_sensitive_information_free"] = Units(input=sensitiveInformationPolicyFreeUnits, output=0) # type: ignore
365
+
366
+ contextualGroundingPolicyUnits = usage.get("contextualGroundingPolicyUnits", 0) # type: ignore
367
+ if contextualGroundingPolicyUnits > 0:
368
+ units["guardrail_contextual_grounding"] = Units(input=contextualGroundingPolicyUnits, output=0) # type: ignore
369
+
370
+ contentPolicyImageUnits = usage.get("contentPolicyImageUnits", 0) # type: ignore
371
+ if contentPolicyImageUnits > 0:
372
+ units["guardrail_content_image"] = Units(input=contentPolicyImageUnits, output=0) # type: ignore
373
+
306
374
  class _BedrockInvokeProviderRequest(_BedrockProviderRequest):
307
375
  def __init__(self, instrumentor: _PayiInstrumentor, model_id: str):
308
376
  super().__init__(instrumentor=instrumentor)
@@ -318,9 +386,22 @@ class _BedrockInvokeProviderRequest(_BedrockProviderRequest):
318
386
 
319
387
  super().process_request(instance, extra_headers, args, kwargs)
320
388
 
389
+ guardrail_id = kwargs.get("guardrailIdentifier", "")
390
+ if guardrail_id:
391
+ self.add_internal_request_property(GUARDRAIL_ID, guardrail_id)
392
+
393
+ guardrail_version = kwargs.get("guardrailVersion", "")
394
+ if guardrail_version:
395
+ self.add_internal_request_property(GUARDRAIL_VERSION, guardrail_version)
396
+
397
+ if guardrail_id and guardrail_version and BedrockInstrumentor._guardrail_trace:
398
+ trace = kwargs.get("trace", None)
399
+ if not trace:
400
+ kwargs["trace"] = "ENABLED"
401
+
321
402
  if self._is_anthropic:
322
403
  try:
323
- body = json.loads( kwargs.get("body", ""))
404
+ body = json.loads(kwargs.get("body", ""))
324
405
  messages = body.get("messages", {})
325
406
  if messages:
326
407
  anthropic_has_image_and_get_texts(self, messages)
@@ -328,7 +409,7 @@ class _BedrockInvokeProviderRequest(_BedrockProviderRequest):
328
409
  self._instrumentor._logger.debug(f"Bedrock invoke error processing request body: {e}")
329
410
  elif self._is_cohere_embed_english_v3:
330
411
  try:
331
- body = json.loads( kwargs.get("body", ""))
412
+ body = json.loads(kwargs.get("body", ""))
332
413
  input_type = body.get("input_type", "")
333
414
  if input_type == 'image':
334
415
  images = body.get("images", [])
@@ -343,6 +424,12 @@ class _BedrockInvokeProviderRequest(_BedrockProviderRequest):
343
424
  def process_chunk(self, chunk: Any) -> _ChunkResult:
344
425
  chunk_dict = json.loads(chunk)
345
426
 
427
+ guardrails = chunk_dict.get("amazon-bedrock-trace", {}).get("guardrail", {}).get("input", {})
428
+ if guardrails:
429
+ self.process_guardrails(guardrails)
430
+
431
+ self.process_stop_action(chunk_dict.get("amazon-bedrock-guardrailAction", ""))
432
+
346
433
  if self._is_anthropic:
347
434
  from .AnthropicInstrumentor import anthropic_process_chunk
348
435
  return anthropic_process_chunk(self, chunk_dict, assign_id=False)
@@ -398,6 +485,13 @@ class _BedrockInvokeProviderRequest(_BedrockProviderRequest):
398
485
 
399
486
  return response
400
487
 
488
+ def process_stop_action(self, action: str) -> None:
489
+ # record both as a semantic failure and guardrail action so it is discoverable through both properties
490
+ if action == "INTERVENED":
491
+ self.add_internal_request_property('system.failure', action)
492
+ self.add_internal_request_property('system.failure.description', GUARDRAIL_SEMANTIC_FAILURE_DESCRIPTION)
493
+ self.add_internal_request_property(GUARDRAIL_ACTION, action)
494
+
401
495
  @override
402
496
  def remove_inline_data(self, prompt: 'dict[str, Any]') -> bool:# noqa: ARG002
403
497
  if not self._is_anthropic:
@@ -417,6 +511,25 @@ class _BedrockInvokeProviderRequest(_BedrockProviderRequest):
417
511
  return False
418
512
 
419
513
  class _BedrockConverseProviderRequest(_BedrockProviderRequest):
514
+ @override
515
+ def process_request(self, instance: Any, extra_headers: 'dict[str, str]', args: Sequence[Any], kwargs: Any) -> bool:
516
+ guardrail_config = kwargs.get("guardrailConfig", {})
517
+ if guardrail_config:
518
+ guardrailIdentifier = guardrail_config.get("guardrailIdentifier", "")
519
+ if guardrailIdentifier:
520
+ self.add_internal_request_property(GUARDRAIL_ID, guardrailIdentifier)
521
+
522
+ guardrailVersion = guardrail_config.get("guardrailVersion", "")
523
+ if guardrailVersion:
524
+ self.add_internal_request_property(GUARDRAIL_VERSION, guardrailVersion)
525
+
526
+ if guardrailIdentifier and guardrailVersion and BedrockInstrumentor._guardrail_trace:
527
+ trace = guardrail_config.get("trace", None)
528
+ if not trace:
529
+ guardrail_config["trace"] = "enabled"
530
+
531
+ return True
532
+
420
533
  @override
421
534
  def process_synchronous_response(
422
535
  self,
@@ -448,6 +561,12 @@ class _BedrockConverseProviderRequest(_BedrockProviderRequest):
448
561
 
449
562
  bedrock_converse_process_synchronous_function_call(self, response)
450
563
 
564
+ guardrails = response.get("trace", {}).get("guardrail", {}).get("inputAssessment", {})
565
+ if guardrails:
566
+ self.process_guardrails(guardrails)
567
+
568
+ self.process_stop_reason(response.get("stopReason", ""))
569
+
451
570
  return None
452
571
 
453
572
  @override
@@ -461,12 +580,25 @@ class _BedrockConverseProviderRequest(_BedrockProviderRequest):
461
580
  output = usage.get("outputTokens", 0)
462
581
  self._ingest["units"]["text"] = Units(input=input, output=output)
463
582
 
583
+ guardrail = metadata.get("trace", {}).get("guardrail", {}).get("inputAssessment", {})
584
+ if guardrail:
585
+ self.process_guardrails(guardrail)
586
+
464
587
  ingest = True
465
588
 
589
+ self.process_stop_reason(chunk.get("messageStop", {}).get("stopReason", ""))
590
+
466
591
  bedrock_converse_process_streaming_for_function_call(self, chunk)
467
592
 
468
593
  return _ChunkResult(send_chunk_to_caller=True, ingest=ingest)
469
594
 
595
+ def process_stop_reason(self, reason: str) -> None:
596
+ if reason == "guardrail_intervened":
597
+ # record both as a semantic failure and guardrail action so it is discoverable through both properties
598
+ self.add_internal_request_property('system.failure', reason)
599
+ self.add_internal_request_property('system.failure.description', GUARDRAIL_SEMANTIC_FAILURE_DESCRIPTION)
600
+ self.add_internal_request_property(GUARDRAIL_ACTION, reason)
601
+
470
602
  def bedrock_converse_process_streaming_for_function_call(request: _ProviderRequest, chunk: 'dict[str, Any]') -> None:
471
603
  contentBlockStart = chunk.get("contentBlockStart", {})
472
604
  tool_use = contentBlockStart.get("start", {}).get("toolUse", {})
@@ -59,6 +59,7 @@ class _ProviderRequest:
59
59
  self._building_function_response: bool = False
60
60
  self._function_calls: Optional[list[ProviderResponseFunctionCall]] = None
61
61
  self._is_large_context: bool = False
62
+ self._internal_request_properties: dict[str, str] = {}
62
63
 
63
64
  def process_chunk(self, _chunk: Any) -> _ChunkResult:
64
65
  return _ChunkResult(send_chunk_to_caller=True)
@@ -99,6 +100,9 @@ class _ProviderRequest:
99
100
  def streaming_type(self) -> '_StreamingType':
100
101
  return self._streaming_type
101
102
 
103
+ def add_internal_request_property(self, key: str, value: str) -> None:
104
+ self._internal_request_properties[key] = value
105
+
102
106
  def exception_to_semantic_failure(self, e: Exception) -> None:
103
107
  exception_str = f"{type(e).__name__}"
104
108
 
@@ -113,16 +117,10 @@ class _ProviderRequest:
113
117
  except Exception as _ex:
114
118
  pass
115
119
 
116
- existing_properties = self._ingest.get("properties", None)
117
- if not existing_properties:
118
- existing_properties = {}
119
-
120
- existing_properties['system.failure'] = exception_str
120
+ self.add_internal_request_property('system.failure', exception_str)
121
121
  if fields:
122
122
  failure_description = ",".join(fields)
123
- existing_properties["system.failure.description"] = failure_description[:128]
124
-
125
- self._ingest["properties"] = existing_properties
123
+ self.add_internal_request_property("system.failure.description", failure_description)
126
124
 
127
125
  if "http_status_code" not in self._ingest:
128
126
  # use a non existent http status code so when presented to the user, the origin is clear
@@ -147,6 +145,9 @@ class _ProviderRequest:
147
145
  self._ingest["provider_response_function_calls"] = self._function_calls
148
146
  self._function_calls.append(ProviderResponseFunctionCall(name=name, arguments=arguments))
149
147
 
148
+ class PayiInstrumentAwsBedrockConfig(TypedDict, total=False):
149
+ guardrail_trace: bool
150
+
150
151
  class PayiInstrumentConfig(TypedDict, total=False):
151
152
  proxy: bool
152
153
  global_instrumentation: bool
@@ -161,6 +162,7 @@ class PayiInstrumentConfig(TypedDict, total=False):
161
162
  account_name: Optional[str]
162
163
  request_tags: Optional["list[str]"]
163
164
  request_properties: Optional["dict[str, str]"]
165
+ aws_config: Optional[PayiInstrumentAwsBedrockConfig]
164
166
 
165
167
  class PayiContext(TypedDict, total=False):
166
168
  use_case_name: Optional[str]
@@ -276,9 +278,9 @@ class _PayiInstrumentor:
276
278
  global_instrumentation = global_config.pop("global_instrumentation", True)
277
279
 
278
280
  if instruments is None or "*" in instruments:
279
- self._instrument_all()
281
+ self._instrument_all(global_config=global_config)
280
282
  else:
281
- self._instrument_specific(instruments)
283
+ self._instrument_specific(instruments=instruments, global_config=global_config)
282
284
 
283
285
  if global_instrumentation:
284
286
  if "proxy" not in global_config:
@@ -313,20 +315,20 @@ class _PayiInstrumentor:
313
315
 
314
316
  self._init_current_context(**context)
315
317
 
316
- def _instrument_all(self) -> None:
318
+ def _instrument_all(self, global_config: PayiInstrumentConfig) -> None:
317
319
  self._instrument_openai()
318
320
  self._instrument_anthropic()
319
- self._instrument_aws_bedrock()
321
+ self._instrument_aws_bedrock(global_config.get("aws_config", None))
320
322
  self._instrument_google_vertex()
321
323
  self._instrument_google_genai()
322
324
 
323
- def _instrument_specific(self, instruments: Set[str]) -> None:
325
+ def _instrument_specific(self, instruments: Set[str], global_config: PayiInstrumentConfig) -> None:
324
326
  if PayiCategories.openai in instruments or PayiCategories.azure_openai in instruments:
325
327
  self._instrument_openai()
326
328
  if PayiCategories.anthropic in instruments:
327
329
  self._instrument_anthropic()
328
330
  if PayiCategories.aws_bedrock in instruments:
329
- self._instrument_aws_bedrock()
331
+ self._instrument_aws_bedrock(global_config.get("aws_config", None))
330
332
  if PayiCategories.google_vertex in instruments:
331
333
  self._instrument_google_vertex()
332
334
  self._instrument_google_genai()
@@ -349,11 +351,11 @@ class _PayiInstrumentor:
349
351
  except Exception as e:
350
352
  self._logger.error(f"Error instrumenting Anthropic: {e}")
351
353
 
352
- def _instrument_aws_bedrock(self) -> None:
354
+ def _instrument_aws_bedrock(self, aws_config: Optional[PayiInstrumentAwsBedrockConfig]) -> None:
353
355
  from .BedrockInstrumentor import BedrockInstrumentor
354
356
 
355
357
  try:
356
- BedrockInstrumentor.instrument(self)
358
+ BedrockInstrumentor.instrument(self, aws_config=aws_config)
357
359
 
358
360
  except Exception as e:
359
361
  self._logger.error(f"Error instrumenting AWS bedrock: {e}")
@@ -393,9 +395,10 @@ class _PayiInstrumentor:
393
395
  return log_ingest_units
394
396
 
395
397
  def _process_ingest_units(
396
- self,
397
- request: _ProviderRequest, log_data: 'dict[str, str]',
398
- extra_headers: 'dict[str, str]') -> None:
398
+ self,
399
+ request: _ProviderRequest,
400
+ log_data: 'dict[str, str]',
401
+ extra_headers: 'dict[str, str]') -> None:
399
402
  ingest_units = request._ingest
400
403
 
401
404
  if request._module_version:
@@ -408,6 +411,9 @@ class _PayiInstrumentor:
408
411
  if 'resource' not in ingest_units or ingest_units['resource'] == '':
409
412
  ingest_units['resource'] = "system.unknown_model"
410
413
 
414
+ if request._internal_request_properties:
415
+ ingest_units["properties"] = request._internal_request_properties
416
+
411
417
  request_json = ingest_units.get('provider_request_json', "")
412
418
  if request_json and self._instrument_inline_data is False:
413
419
  try:
@@ -925,6 +931,15 @@ class _PayiInstrumentor:
925
931
  if use_case_properties:
926
932
  request._ingest["use_case_properties"] = use_case_properties
927
933
 
934
+ if request._internal_request_properties:
935
+ if "properties" in request._ingest and request._ingest["properties"] is not None:
936
+ # Merge internal request properties, but don't override existing keys
937
+ for key, value in request._internal_request_properties.items():
938
+ if key not in request._ingest["properties"]:
939
+ request._ingest["properties"][key] = value
940
+ else:
941
+ request._ingest["properties"] = request._internal_request_properties # Assign
942
+
928
943
  if len(ingest_extra_headers) > 0:
929
944
  request._ingest["provider_request_headers"] = [PayICommonModelsAPIRouterHeaderInfoParam(name=k, value=v) for k, v in ingest_extra_headers.items()]
930
945
 
@@ -6,13 +6,10 @@ import gc
6
6
  import os
7
7
  import sys
8
8
  import json
9
- import time
10
9
  import asyncio
11
10
  import inspect
12
- import subprocess
13
11
  import tracemalloc
14
12
  from typing import Any, Union, cast
15
- from textwrap import dedent
16
13
  from unittest import mock
17
14
  from typing_extensions import Literal
18
15
 
@@ -23,14 +20,17 @@ from pydantic import ValidationError
23
20
 
24
21
  from payi import Payi, AsyncPayi, APIResponseValidationError
25
22
  from payi._types import Omit
23
+ from payi._utils import asyncify
26
24
  from payi._models import BaseModel, FinalRequestOptions
27
25
  from payi._exceptions import PayiError, APIStatusError, APITimeoutError, APIResponseValidationError
28
26
  from payi._base_client import (
29
27
  DEFAULT_TIMEOUT,
30
28
  HTTPX_DEFAULT_TIMEOUT,
31
29
  BaseClient,
30
+ OtherPlatform,
32
31
  DefaultHttpxClient,
33
32
  DefaultAsyncHttpxClient,
33
+ get_platform,
34
34
  make_request_options,
35
35
  )
36
36
 
@@ -1617,50 +1617,9 @@ class TestAsyncPayi:
1617
1617
 
1618
1618
  assert response.http_request.headers.get("x-stainless-retry-count") == "42"
1619
1619
 
1620
- def test_get_platform(self) -> None:
1621
- # A previous implementation of asyncify could leave threads unterminated when
1622
- # used with nest_asyncio.
1623
- #
1624
- # Since nest_asyncio.apply() is global and cannot be un-applied, this
1625
- # test is run in a separate process to avoid affecting other tests.
1626
- test_code = dedent("""
1627
- import asyncio
1628
- import nest_asyncio
1629
- import threading
1630
-
1631
- from payi._utils import asyncify
1632
- from payi._base_client import get_platform
1633
-
1634
- async def test_main() -> None:
1635
- result = await asyncify(get_platform)()
1636
- print(result)
1637
- for thread in threading.enumerate():
1638
- print(thread.name)
1639
-
1640
- nest_asyncio.apply()
1641
- asyncio.run(test_main())
1642
- """)
1643
- with subprocess.Popen(
1644
- [sys.executable, "-c", test_code],
1645
- text=True,
1646
- ) as process:
1647
- timeout = 10 # seconds
1648
-
1649
- start_time = time.monotonic()
1650
- while True:
1651
- return_code = process.poll()
1652
- if return_code is not None:
1653
- if return_code != 0:
1654
- raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1655
-
1656
- # success
1657
- break
1658
-
1659
- if time.monotonic() - start_time > timeout:
1660
- process.kill()
1661
- raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1662
-
1663
- time.sleep(0.1)
1620
+ async def test_get_platform(self) -> None:
1621
+ platform = await asyncify(get_platform)()
1622
+ assert isinstance(platform, (str, OtherPlatform))
1664
1623
 
1665
1624
  async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None:
1666
1625
  # Test that the proxy environment variables are set correctly
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.1.0-alpha.115"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes