flyte 0.0.1b0__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 flyte might be problematic. Click here for more details.

Files changed (390) hide show
  1. flyte/__init__.py +62 -0
  2. flyte/_api_commons.py +3 -0
  3. flyte/_bin/__init__.py +0 -0
  4. flyte/_bin/runtime.py +126 -0
  5. flyte/_build.py +25 -0
  6. flyte/_cache/__init__.py +12 -0
  7. flyte/_cache/cache.py +146 -0
  8. flyte/_cache/defaults.py +9 -0
  9. flyte/_cache/policy_function_body.py +42 -0
  10. flyte/_cli/__init__.py +0 -0
  11. flyte/_cli/_common.py +287 -0
  12. flyte/_cli/_create.py +42 -0
  13. flyte/_cli/_delete.py +23 -0
  14. flyte/_cli/_deploy.py +140 -0
  15. flyte/_cli/_get.py +235 -0
  16. flyte/_cli/_run.py +152 -0
  17. flyte/_cli/main.py +72 -0
  18. flyte/_code_bundle/__init__.py +8 -0
  19. flyte/_code_bundle/_ignore.py +113 -0
  20. flyte/_code_bundle/_packaging.py +187 -0
  21. flyte/_code_bundle/_utils.py +339 -0
  22. flyte/_code_bundle/bundle.py +178 -0
  23. flyte/_context.py +146 -0
  24. flyte/_datastructures.py +342 -0
  25. flyte/_deploy.py +202 -0
  26. flyte/_doc.py +29 -0
  27. flyte/_docstring.py +32 -0
  28. flyte/_environment.py +43 -0
  29. flyte/_group.py +31 -0
  30. flyte/_hash.py +23 -0
  31. flyte/_image.py +760 -0
  32. flyte/_initialize.py +634 -0
  33. flyte/_interface.py +84 -0
  34. flyte/_internal/__init__.py +3 -0
  35. flyte/_internal/controllers/__init__.py +115 -0
  36. flyte/_internal/controllers/_local_controller.py +118 -0
  37. flyte/_internal/controllers/_trace.py +40 -0
  38. flyte/_internal/controllers/pbhash.py +39 -0
  39. flyte/_internal/controllers/remote/__init__.py +40 -0
  40. flyte/_internal/controllers/remote/_action.py +141 -0
  41. flyte/_internal/controllers/remote/_client.py +43 -0
  42. flyte/_internal/controllers/remote/_controller.py +361 -0
  43. flyte/_internal/controllers/remote/_core.py +402 -0
  44. flyte/_internal/controllers/remote/_informer.py +361 -0
  45. flyte/_internal/controllers/remote/_service_protocol.py +50 -0
  46. flyte/_internal/imagebuild/__init__.py +11 -0
  47. flyte/_internal/imagebuild/docker_builder.py +416 -0
  48. flyte/_internal/imagebuild/image_builder.py +241 -0
  49. flyte/_internal/imagebuild/remote_builder.py +0 -0
  50. flyte/_internal/resolvers/__init__.py +0 -0
  51. flyte/_internal/resolvers/_task_module.py +54 -0
  52. flyte/_internal/resolvers/common.py +31 -0
  53. flyte/_internal/resolvers/default.py +28 -0
  54. flyte/_internal/runtime/__init__.py +0 -0
  55. flyte/_internal/runtime/convert.py +199 -0
  56. flyte/_internal/runtime/entrypoints.py +135 -0
  57. flyte/_internal/runtime/io.py +136 -0
  58. flyte/_internal/runtime/resources_serde.py +138 -0
  59. flyte/_internal/runtime/task_serde.py +210 -0
  60. flyte/_internal/runtime/taskrunner.py +190 -0
  61. flyte/_internal/runtime/types_serde.py +54 -0
  62. flyte/_logging.py +124 -0
  63. flyte/_protos/__init__.py +0 -0
  64. flyte/_protos/common/authorization_pb2.py +66 -0
  65. flyte/_protos/common/authorization_pb2.pyi +108 -0
  66. flyte/_protos/common/authorization_pb2_grpc.py +4 -0
  67. flyte/_protos/common/identifier_pb2.py +71 -0
  68. flyte/_protos/common/identifier_pb2.pyi +82 -0
  69. flyte/_protos/common/identifier_pb2_grpc.py +4 -0
  70. flyte/_protos/common/identity_pb2.py +48 -0
  71. flyte/_protos/common/identity_pb2.pyi +72 -0
  72. flyte/_protos/common/identity_pb2_grpc.py +4 -0
  73. flyte/_protos/common/list_pb2.py +36 -0
  74. flyte/_protos/common/list_pb2.pyi +69 -0
  75. flyte/_protos/common/list_pb2_grpc.py +4 -0
  76. flyte/_protos/common/policy_pb2.py +37 -0
  77. flyte/_protos/common/policy_pb2.pyi +27 -0
  78. flyte/_protos/common/policy_pb2_grpc.py +4 -0
  79. flyte/_protos/common/role_pb2.py +37 -0
  80. flyte/_protos/common/role_pb2.pyi +53 -0
  81. flyte/_protos/common/role_pb2_grpc.py +4 -0
  82. flyte/_protos/common/runtime_version_pb2.py +28 -0
  83. flyte/_protos/common/runtime_version_pb2.pyi +24 -0
  84. flyte/_protos/common/runtime_version_pb2_grpc.py +4 -0
  85. flyte/_protos/logs/dataplane/payload_pb2.py +96 -0
  86. flyte/_protos/logs/dataplane/payload_pb2.pyi +168 -0
  87. flyte/_protos/logs/dataplane/payload_pb2_grpc.py +4 -0
  88. flyte/_protos/secret/definition_pb2.py +49 -0
  89. flyte/_protos/secret/definition_pb2.pyi +93 -0
  90. flyte/_protos/secret/definition_pb2_grpc.py +4 -0
  91. flyte/_protos/secret/payload_pb2.py +62 -0
  92. flyte/_protos/secret/payload_pb2.pyi +94 -0
  93. flyte/_protos/secret/payload_pb2_grpc.py +4 -0
  94. flyte/_protos/secret/secret_pb2.py +38 -0
  95. flyte/_protos/secret/secret_pb2.pyi +6 -0
  96. flyte/_protos/secret/secret_pb2_grpc.py +198 -0
  97. flyte/_protos/secret/secret_pb2_grpc_grpc.py +198 -0
  98. flyte/_protos/validate/validate/validate_pb2.py +76 -0
  99. flyte/_protos/workflow/node_execution_service_pb2.py +26 -0
  100. flyte/_protos/workflow/node_execution_service_pb2.pyi +4 -0
  101. flyte/_protos/workflow/node_execution_service_pb2_grpc.py +32 -0
  102. flyte/_protos/workflow/queue_service_pb2.py +106 -0
  103. flyte/_protos/workflow/queue_service_pb2.pyi +141 -0
  104. flyte/_protos/workflow/queue_service_pb2_grpc.py +172 -0
  105. flyte/_protos/workflow/run_definition_pb2.py +128 -0
  106. flyte/_protos/workflow/run_definition_pb2.pyi +310 -0
  107. flyte/_protos/workflow/run_definition_pb2_grpc.py +4 -0
  108. flyte/_protos/workflow/run_logs_service_pb2.py +41 -0
  109. flyte/_protos/workflow/run_logs_service_pb2.pyi +28 -0
  110. flyte/_protos/workflow/run_logs_service_pb2_grpc.py +69 -0
  111. flyte/_protos/workflow/run_service_pb2.py +133 -0
  112. flyte/_protos/workflow/run_service_pb2.pyi +175 -0
  113. flyte/_protos/workflow/run_service_pb2_grpc.py +412 -0
  114. flyte/_protos/workflow/state_service_pb2.py +58 -0
  115. flyte/_protos/workflow/state_service_pb2.pyi +71 -0
  116. flyte/_protos/workflow/state_service_pb2_grpc.py +138 -0
  117. flyte/_protos/workflow/task_definition_pb2.py +72 -0
  118. flyte/_protos/workflow/task_definition_pb2.pyi +65 -0
  119. flyte/_protos/workflow/task_definition_pb2_grpc.py +4 -0
  120. flyte/_protos/workflow/task_service_pb2.py +44 -0
  121. flyte/_protos/workflow/task_service_pb2.pyi +31 -0
  122. flyte/_protos/workflow/task_service_pb2_grpc.py +104 -0
  123. flyte/_resources.py +226 -0
  124. flyte/_retry.py +32 -0
  125. flyte/_reusable_environment.py +25 -0
  126. flyte/_run.py +411 -0
  127. flyte/_secret.py +61 -0
  128. flyte/_task.py +367 -0
  129. flyte/_task_environment.py +200 -0
  130. flyte/_timeout.py +47 -0
  131. flyte/_tools.py +27 -0
  132. flyte/_trace.py +128 -0
  133. flyte/_utils/__init__.py +20 -0
  134. flyte/_utils/asyn.py +119 -0
  135. flyte/_utils/coro_management.py +25 -0
  136. flyte/_utils/file_handling.py +72 -0
  137. flyte/_utils/helpers.py +108 -0
  138. flyte/_utils/lazy_module.py +54 -0
  139. flyte/_utils/uv_script_parser.py +49 -0
  140. flyte/_version.py +21 -0
  141. flyte/connectors/__init__.py +0 -0
  142. flyte/errors.py +143 -0
  143. flyte/extras/__init__.py +5 -0
  144. flyte/extras/_container.py +273 -0
  145. flyte/io/__init__.py +11 -0
  146. flyte/io/_dataframe.py +0 -0
  147. flyte/io/_dir.py +448 -0
  148. flyte/io/_file.py +468 -0
  149. flyte/io/pickle/__init__.py +0 -0
  150. flyte/io/pickle/transformer.py +117 -0
  151. flyte/io/structured_dataset/__init__.py +129 -0
  152. flyte/io/structured_dataset/basic_dfs.py +219 -0
  153. flyte/io/structured_dataset/structured_dataset.py +1061 -0
  154. flyte/py.typed +0 -0
  155. flyte/remote/__init__.py +25 -0
  156. flyte/remote/_client/__init__.py +0 -0
  157. flyte/remote/_client/_protocols.py +131 -0
  158. flyte/remote/_client/auth/__init__.py +12 -0
  159. flyte/remote/_client/auth/_authenticators/__init__.py +0 -0
  160. flyte/remote/_client/auth/_authenticators/base.py +397 -0
  161. flyte/remote/_client/auth/_authenticators/client_credentials.py +73 -0
  162. flyte/remote/_client/auth/_authenticators/device_code.py +118 -0
  163. flyte/remote/_client/auth/_authenticators/external_command.py +79 -0
  164. flyte/remote/_client/auth/_authenticators/factory.py +200 -0
  165. flyte/remote/_client/auth/_authenticators/pkce.py +516 -0
  166. flyte/remote/_client/auth/_channel.py +184 -0
  167. flyte/remote/_client/auth/_client_config.py +83 -0
  168. flyte/remote/_client/auth/_default_html.py +32 -0
  169. flyte/remote/_client/auth/_grpc_utils/__init__.py +0 -0
  170. flyte/remote/_client/auth/_grpc_utils/auth_interceptor.py +288 -0
  171. flyte/remote/_client/auth/_grpc_utils/default_metadata_interceptor.py +151 -0
  172. flyte/remote/_client/auth/_keyring.py +143 -0
  173. flyte/remote/_client/auth/_token_client.py +260 -0
  174. flyte/remote/_client/auth/errors.py +16 -0
  175. flyte/remote/_client/controlplane.py +95 -0
  176. flyte/remote/_console.py +18 -0
  177. flyte/remote/_data.py +155 -0
  178. flyte/remote/_logs.py +116 -0
  179. flyte/remote/_project.py +86 -0
  180. flyte/remote/_run.py +873 -0
  181. flyte/remote/_secret.py +132 -0
  182. flyte/remote/_task.py +227 -0
  183. flyte/report/__init__.py +3 -0
  184. flyte/report/_report.py +178 -0
  185. flyte/report/_template.html +124 -0
  186. flyte/storage/__init__.py +24 -0
  187. flyte/storage/_remote_fs.py +34 -0
  188. flyte/storage/_storage.py +251 -0
  189. flyte/storage/_utils.py +5 -0
  190. flyte/types/__init__.py +13 -0
  191. flyte/types/_interface.py +25 -0
  192. flyte/types/_renderer.py +162 -0
  193. flyte/types/_string_literals.py +120 -0
  194. flyte/types/_type_engine.py +2210 -0
  195. flyte/types/_utils.py +80 -0
  196. flyte-0.0.1b0.dist-info/METADATA +179 -0
  197. flyte-0.0.1b0.dist-info/RECORD +390 -0
  198. flyte-0.0.1b0.dist-info/WHEEL +5 -0
  199. flyte-0.0.1b0.dist-info/entry_points.txt +3 -0
  200. flyte-0.0.1b0.dist-info/top_level.txt +1 -0
  201. union/__init__.py +54 -0
  202. union/_api_commons.py +3 -0
  203. union/_bin/__init__.py +0 -0
  204. union/_bin/runtime.py +113 -0
  205. union/_build.py +25 -0
  206. union/_cache/__init__.py +12 -0
  207. union/_cache/cache.py +141 -0
  208. union/_cache/defaults.py +9 -0
  209. union/_cache/policy_function_body.py +42 -0
  210. union/_cli/__init__.py +0 -0
  211. union/_cli/_common.py +263 -0
  212. union/_cli/_create.py +40 -0
  213. union/_cli/_delete.py +23 -0
  214. union/_cli/_deploy.py +120 -0
  215. union/_cli/_get.py +162 -0
  216. union/_cli/_params.py +579 -0
  217. union/_cli/_run.py +150 -0
  218. union/_cli/main.py +72 -0
  219. union/_code_bundle/__init__.py +8 -0
  220. union/_code_bundle/_ignore.py +113 -0
  221. union/_code_bundle/_packaging.py +187 -0
  222. union/_code_bundle/_utils.py +342 -0
  223. union/_code_bundle/bundle.py +176 -0
  224. union/_context.py +146 -0
  225. union/_datastructures.py +295 -0
  226. union/_deploy.py +185 -0
  227. union/_doc.py +29 -0
  228. union/_docstring.py +26 -0
  229. union/_environment.py +43 -0
  230. union/_group.py +31 -0
  231. union/_hash.py +23 -0
  232. union/_image.py +760 -0
  233. union/_initialize.py +585 -0
  234. union/_interface.py +84 -0
  235. union/_internal/__init__.py +3 -0
  236. union/_internal/controllers/__init__.py +77 -0
  237. union/_internal/controllers/_local_controller.py +77 -0
  238. union/_internal/controllers/pbhash.py +39 -0
  239. union/_internal/controllers/remote/__init__.py +40 -0
  240. union/_internal/controllers/remote/_action.py +131 -0
  241. union/_internal/controllers/remote/_client.py +43 -0
  242. union/_internal/controllers/remote/_controller.py +169 -0
  243. union/_internal/controllers/remote/_core.py +341 -0
  244. union/_internal/controllers/remote/_informer.py +260 -0
  245. union/_internal/controllers/remote/_service_protocol.py +44 -0
  246. union/_internal/imagebuild/__init__.py +11 -0
  247. union/_internal/imagebuild/docker_builder.py +416 -0
  248. union/_internal/imagebuild/image_builder.py +243 -0
  249. union/_internal/imagebuild/remote_builder.py +0 -0
  250. union/_internal/resolvers/__init__.py +0 -0
  251. union/_internal/resolvers/_task_module.py +31 -0
  252. union/_internal/resolvers/common.py +24 -0
  253. union/_internal/resolvers/default.py +27 -0
  254. union/_internal/runtime/__init__.py +0 -0
  255. union/_internal/runtime/convert.py +163 -0
  256. union/_internal/runtime/entrypoints.py +121 -0
  257. union/_internal/runtime/io.py +136 -0
  258. union/_internal/runtime/resources_serde.py +134 -0
  259. union/_internal/runtime/task_serde.py +202 -0
  260. union/_internal/runtime/taskrunner.py +179 -0
  261. union/_internal/runtime/types_serde.py +53 -0
  262. union/_logging.py +124 -0
  263. union/_protos/__init__.py +0 -0
  264. union/_protos/common/authorization_pb2.py +66 -0
  265. union/_protos/common/authorization_pb2.pyi +106 -0
  266. union/_protos/common/authorization_pb2_grpc.py +4 -0
  267. union/_protos/common/identifier_pb2.py +71 -0
  268. union/_protos/common/identifier_pb2.pyi +82 -0
  269. union/_protos/common/identifier_pb2_grpc.py +4 -0
  270. union/_protos/common/identity_pb2.py +48 -0
  271. union/_protos/common/identity_pb2.pyi +72 -0
  272. union/_protos/common/identity_pb2_grpc.py +4 -0
  273. union/_protos/common/list_pb2.py +36 -0
  274. union/_protos/common/list_pb2.pyi +69 -0
  275. union/_protos/common/list_pb2_grpc.py +4 -0
  276. union/_protos/common/policy_pb2.py +37 -0
  277. union/_protos/common/policy_pb2.pyi +27 -0
  278. union/_protos/common/policy_pb2_grpc.py +4 -0
  279. union/_protos/common/role_pb2.py +37 -0
  280. union/_protos/common/role_pb2.pyi +51 -0
  281. union/_protos/common/role_pb2_grpc.py +4 -0
  282. union/_protos/common/runtime_version_pb2.py +28 -0
  283. union/_protos/common/runtime_version_pb2.pyi +24 -0
  284. union/_protos/common/runtime_version_pb2_grpc.py +4 -0
  285. union/_protos/logs/dataplane/payload_pb2.py +96 -0
  286. union/_protos/logs/dataplane/payload_pb2.pyi +168 -0
  287. union/_protos/logs/dataplane/payload_pb2_grpc.py +4 -0
  288. union/_protos/secret/definition_pb2.py +49 -0
  289. union/_protos/secret/definition_pb2.pyi +93 -0
  290. union/_protos/secret/definition_pb2_grpc.py +4 -0
  291. union/_protos/secret/payload_pb2.py +62 -0
  292. union/_protos/secret/payload_pb2.pyi +94 -0
  293. union/_protos/secret/payload_pb2_grpc.py +4 -0
  294. union/_protos/secret/secret_pb2.py +38 -0
  295. union/_protos/secret/secret_pb2.pyi +6 -0
  296. union/_protos/secret/secret_pb2_grpc.py +198 -0
  297. union/_protos/validate/validate/validate_pb2.py +76 -0
  298. union/_protos/workflow/node_execution_service_pb2.py +26 -0
  299. union/_protos/workflow/node_execution_service_pb2.pyi +4 -0
  300. union/_protos/workflow/node_execution_service_pb2_grpc.py +32 -0
  301. union/_protos/workflow/queue_service_pb2.py +75 -0
  302. union/_protos/workflow/queue_service_pb2.pyi +103 -0
  303. union/_protos/workflow/queue_service_pb2_grpc.py +172 -0
  304. union/_protos/workflow/run_definition_pb2.py +100 -0
  305. union/_protos/workflow/run_definition_pb2.pyi +256 -0
  306. union/_protos/workflow/run_definition_pb2_grpc.py +4 -0
  307. union/_protos/workflow/run_logs_service_pb2.py +41 -0
  308. union/_protos/workflow/run_logs_service_pb2.pyi +28 -0
  309. union/_protos/workflow/run_logs_service_pb2_grpc.py +69 -0
  310. union/_protos/workflow/run_service_pb2.py +133 -0
  311. union/_protos/workflow/run_service_pb2.pyi +173 -0
  312. union/_protos/workflow/run_service_pb2_grpc.py +412 -0
  313. union/_protos/workflow/state_service_pb2.py +58 -0
  314. union/_protos/workflow/state_service_pb2.pyi +69 -0
  315. union/_protos/workflow/state_service_pb2_grpc.py +138 -0
  316. union/_protos/workflow/task_definition_pb2.py +72 -0
  317. union/_protos/workflow/task_definition_pb2.pyi +65 -0
  318. union/_protos/workflow/task_definition_pb2_grpc.py +4 -0
  319. union/_protos/workflow/task_service_pb2.py +44 -0
  320. union/_protos/workflow/task_service_pb2.pyi +31 -0
  321. union/_protos/workflow/task_service_pb2_grpc.py +104 -0
  322. union/_resources.py +226 -0
  323. union/_retry.py +32 -0
  324. union/_reusable_environment.py +25 -0
  325. union/_run.py +374 -0
  326. union/_secret.py +61 -0
  327. union/_task.py +354 -0
  328. union/_task_environment.py +186 -0
  329. union/_timeout.py +47 -0
  330. union/_tools.py +27 -0
  331. union/_utils/__init__.py +11 -0
  332. union/_utils/asyn.py +119 -0
  333. union/_utils/file_handling.py +71 -0
  334. union/_utils/helpers.py +46 -0
  335. union/_utils/lazy_module.py +54 -0
  336. union/_utils/uv_script_parser.py +49 -0
  337. union/_version.py +21 -0
  338. union/connectors/__init__.py +0 -0
  339. union/errors.py +128 -0
  340. union/extras/__init__.py +5 -0
  341. union/extras/_container.py +263 -0
  342. union/io/__init__.py +11 -0
  343. union/io/_dataframe.py +0 -0
  344. union/io/_dir.py +425 -0
  345. union/io/_file.py +418 -0
  346. union/io/pickle/__init__.py +0 -0
  347. union/io/pickle/transformer.py +117 -0
  348. union/io/structured_dataset/__init__.py +122 -0
  349. union/io/structured_dataset/basic_dfs.py +219 -0
  350. union/io/structured_dataset/structured_dataset.py +1057 -0
  351. union/py.typed +0 -0
  352. union/remote/__init__.py +23 -0
  353. union/remote/_client/__init__.py +0 -0
  354. union/remote/_client/_protocols.py +129 -0
  355. union/remote/_client/auth/__init__.py +12 -0
  356. union/remote/_client/auth/_authenticators/__init__.py +0 -0
  357. union/remote/_client/auth/_authenticators/base.py +391 -0
  358. union/remote/_client/auth/_authenticators/client_credentials.py +73 -0
  359. union/remote/_client/auth/_authenticators/device_code.py +120 -0
  360. union/remote/_client/auth/_authenticators/external_command.py +77 -0
  361. union/remote/_client/auth/_authenticators/factory.py +200 -0
  362. union/remote/_client/auth/_authenticators/pkce.py +515 -0
  363. union/remote/_client/auth/_channel.py +184 -0
  364. union/remote/_client/auth/_client_config.py +83 -0
  365. union/remote/_client/auth/_default_html.py +32 -0
  366. union/remote/_client/auth/_grpc_utils/__init__.py +0 -0
  367. union/remote/_client/auth/_grpc_utils/auth_interceptor.py +204 -0
  368. union/remote/_client/auth/_grpc_utils/default_metadata_interceptor.py +144 -0
  369. union/remote/_client/auth/_keyring.py +154 -0
  370. union/remote/_client/auth/_token_client.py +258 -0
  371. union/remote/_client/auth/errors.py +16 -0
  372. union/remote/_client/controlplane.py +86 -0
  373. union/remote/_data.py +149 -0
  374. union/remote/_logs.py +74 -0
  375. union/remote/_project.py +86 -0
  376. union/remote/_run.py +820 -0
  377. union/remote/_secret.py +132 -0
  378. union/remote/_task.py +193 -0
  379. union/report/__init__.py +3 -0
  380. union/report/_report.py +178 -0
  381. union/report/_template.html +124 -0
  382. union/storage/__init__.py +24 -0
  383. union/storage/_remote_fs.py +34 -0
  384. union/storage/_storage.py +247 -0
  385. union/storage/_utils.py +5 -0
  386. union/types/__init__.py +11 -0
  387. union/types/_renderer.py +162 -0
  388. union/types/_string_literals.py +120 -0
  389. union/types/_type_engine.py +2131 -0
  390. union/types/_utils.py +80 -0
flyte/_initialize.py ADDED
@@ -0,0 +1,634 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ import functools
5
+ import os
6
+ import threading
7
+ import typing
8
+ from dataclasses import dataclass, replace
9
+ from datetime import timedelta
10
+ from pathlib import Path
11
+ from typing import TYPE_CHECKING, Any, Callable, ClassVar, Dict, List, Literal, Optional, TypeVar
12
+
13
+ from flyte.errors import InitializationError
14
+
15
+ from ._api_commons import syncer
16
+ from ._logging import initialize_logger
17
+ from ._tools import ipython_check
18
+
19
+ if TYPE_CHECKING:
20
+ from flyte.remote._client.auth import AuthType, ClientConfig
21
+ from flyte.remote._client.controlplane import ClientSet
22
+
23
+ Mode = Literal["local", "remote"]
24
+
25
+
26
+ def set_if_exists(d: dict, k: str, val: typing.Any) -> dict:
27
+ """
28
+ Given a dict ``d`` sets the key ``k`` with value of config ``v``, if the config value ``v`` is set
29
+ and return the updated dictionary.
30
+ """
31
+ exists = isinstance(val, bool) or bool(val is not None and val)
32
+ if exists:
33
+ d[k] = val
34
+ return d
35
+
36
+
37
+ @dataclass(init=True, repr=True, eq=True, frozen=True)
38
+ class Storage(object):
39
+ """
40
+ Data storage configuration that applies across any provider.
41
+ """
42
+
43
+ retries: int = 3
44
+ backoff: datetime.timedelta = datetime.timedelta(seconds=5)
45
+ enable_debug: bool = False
46
+ attach_execution_metadata: bool = True
47
+
48
+ _KEY_ENV_VAR_MAPPING: ClassVar[typing.Dict[str, str]] = {
49
+ "enable_debug": "UNION_STORAGE_DEBUG",
50
+ "retries": "UNION_STORAGE_RETRIES",
51
+ "backoff": "UNION_STORAGE_BACKOFF_SECONDS",
52
+ }
53
+
54
+ def get_fsspec_kwargs(self, anonymous: bool = False, /, **kwargs) -> Dict[str, Any]:
55
+ """
56
+ Returns the configuration as kwargs for constructing an fsspec filesystem.
57
+ """
58
+ return {}
59
+
60
+ @classmethod
61
+ def _auto_as_kwargs(cls) -> Dict[str, Any]:
62
+ retries = os.getenv(cls._KEY_ENV_VAR_MAPPING["retries"])
63
+ backoff = os.getenv(cls._KEY_ENV_VAR_MAPPING["backoff"])
64
+ enable_debug = os.getenv(cls._KEY_ENV_VAR_MAPPING["enable_debug"])
65
+
66
+ kwargs: Dict[str, Any] = {}
67
+ kwargs = set_if_exists(kwargs, "enable_debug", enable_debug)
68
+ kwargs = set_if_exists(kwargs, "retries", retries)
69
+ kwargs = set_if_exists(kwargs, "backoff", backoff)
70
+ return kwargs
71
+
72
+ @classmethod
73
+ def auto(cls) -> Storage:
74
+ """
75
+ Construct the config object automatically from environment variables.
76
+ """
77
+ return cls(**cls._auto_as_kwargs())
78
+
79
+
80
+ @dataclass(init=True, repr=True, eq=True, frozen=True)
81
+ class S3(Storage):
82
+ """
83
+ S3 specific configuration
84
+ """
85
+
86
+ endpoint: typing.Optional[str] = None
87
+ access_key_id: typing.Optional[str] = None
88
+ secret_access_key: typing.Optional[str] = None
89
+
90
+ _KEY_ENV_VAR_MAPPING: ClassVar[typing.Dict[str, str]] = {
91
+ "endpoint": "FLYTE_AWS_ENDPOINT",
92
+ "access_key_id": "FLYTE_AWS_ACCESS_KEY_ID",
93
+ "secret_access_key": "FLYTE_AWS_SECRET_ACCESS_KEY",
94
+ } | Storage._KEY_ENV_VAR_MAPPING
95
+
96
+ # Refer to https://github.com/developmentseed/obstore/blob/33654fc37f19a657689eb93327b621e9f9e01494/obstore/python/obstore/store/_aws.pyi#L11
97
+ # for key and secret
98
+ _CONFIG_KEY_FSSPEC_S3_KEY_ID: ClassVar = "access_key_id"
99
+ _CONFIG_KEY_FSSPEC_S3_SECRET: ClassVar = "secret_access_key"
100
+ _CONFIG_KEY_ENDPOINT: ClassVar = "endpoint_url"
101
+ _KEY_SKIP_SIGNATURE: ClassVar = "skip_signature"
102
+
103
+ @classmethod
104
+ def auto(cls) -> S3:
105
+ """
106
+ :return: Config
107
+ """
108
+ endpoint = os.getenv(cls._KEY_ENV_VAR_MAPPING["endpoint"], None)
109
+ access_key_id = os.getenv(cls._KEY_ENV_VAR_MAPPING["access_key_id"], None)
110
+ secret_access_key = os.getenv(cls._KEY_ENV_VAR_MAPPING["secret_access_key"], None)
111
+
112
+ kwargs = super()._auto_as_kwargs()
113
+ kwargs = set_if_exists(kwargs, "endpoint", endpoint)
114
+ kwargs = set_if_exists(kwargs, "access_key_id", access_key_id)
115
+ kwargs = set_if_exists(kwargs, "secret_access_key", secret_access_key)
116
+
117
+ return S3(**kwargs)
118
+
119
+ @classmethod
120
+ def for_sandbox(cls) -> S3:
121
+ """
122
+ :return:
123
+ """
124
+ kwargs = super()._auto_as_kwargs()
125
+ final_kwargs = kwargs | {
126
+ "endpoint": "http://localhost:4566",
127
+ "access_key_id": "minio",
128
+ "secret_access_key": "miniostorage",
129
+ }
130
+ return S3(**final_kwargs)
131
+
132
+ def get_fsspec_kwargs(self, anonymous: bool = False, /, **kwargs) -> Dict[str, Any]:
133
+ # Construct the config object
134
+ config: Dict[str, Any] = {}
135
+ if self._CONFIG_KEY_FSSPEC_S3_KEY_ID in kwargs or self.access_key_id:
136
+ config[self._CONFIG_KEY_FSSPEC_S3_KEY_ID] = kwargs.pop(
137
+ self._CONFIG_KEY_FSSPEC_S3_KEY_ID, self.access_key_id
138
+ )
139
+ if self._CONFIG_KEY_FSSPEC_S3_SECRET in kwargs or self.secret_access_key:
140
+ config[self._CONFIG_KEY_FSSPEC_S3_SECRET] = kwargs.pop(
141
+ self._CONFIG_KEY_FSSPEC_S3_SECRET, self.secret_access_key
142
+ )
143
+ if self._CONFIG_KEY_ENDPOINT in kwargs or self.endpoint:
144
+ config["endpoint_url"] = kwargs.pop(self._CONFIG_KEY_ENDPOINT, self.endpoint)
145
+
146
+ retries = kwargs.pop("retries", self.retries)
147
+ backoff = kwargs.pop("backoff", self.backoff)
148
+
149
+ if anonymous:
150
+ config[self._KEY_SKIP_SIGNATURE] = True
151
+
152
+ retry_config = {
153
+ "max_retries": retries,
154
+ "backoff": {
155
+ "base": 2,
156
+ "init_backoff": backoff,
157
+ "max_backoff": timedelta(seconds=16),
158
+ },
159
+ "retry_timeout": timedelta(minutes=3),
160
+ }
161
+
162
+ client_options = {"timeout": "99999s", "allow_http": True}
163
+
164
+ if config:
165
+ kwargs["config"] = config
166
+ kwargs["client_options"] = client_options or None
167
+ kwargs["retry_config"] = retry_config or None
168
+
169
+ return kwargs
170
+
171
+
172
+ @dataclass(init=True, repr=True, eq=True, frozen=True)
173
+ class GCS(Storage):
174
+ """
175
+ Any GCS specific configuration.
176
+ """
177
+
178
+ gsutil_parallelism: bool = False
179
+
180
+ _KEY_ENV_VAR_MAPPING: ClassVar[dict[str, str]] = {
181
+ "gsutil_parallelism": "GCP_GSUTIL_PARALLELISM",
182
+ }
183
+
184
+ @classmethod
185
+ def auto(cls) -> GCS:
186
+ gsutil_parallelism = os.getenv(cls._KEY_ENV_VAR_MAPPING["gsutil_parallelism"], None)
187
+
188
+ kwargs: Dict[str, Any] = {}
189
+ kwargs = set_if_exists(kwargs, "gsutil_parallelism", gsutil_parallelism)
190
+ return GCS(**kwargs)
191
+
192
+ def get_fsspec_kwargs(self, anonymous: bool = False, /, **kwargs) -> Dict[str, Any]:
193
+ return kwargs
194
+
195
+
196
+ @dataclass(init=True, repr=True, eq=True, frozen=True)
197
+ class ABFS(Storage):
198
+ """
199
+ Any Azure Blob Storage specific configuration.
200
+ """
201
+
202
+ account_name: typing.Optional[str] = None
203
+ account_key: typing.Optional[str] = None
204
+ tenant_id: typing.Optional[str] = None
205
+ client_id: typing.Optional[str] = None
206
+ client_secret: typing.Optional[str] = None
207
+
208
+ _KEY_ENV_VAR_MAPPING: ClassVar[dict[str, str]] = {
209
+ "account_name": "AZURE_STORAGE_ACCOUNT_NAME",
210
+ "account_key": "AZURE_STORAGE_ACCOUNT_KEY",
211
+ "tenant_id": "AZURE_TENANT_ID",
212
+ "client_id": "AZURE_CLIENT_ID",
213
+ "client_secret": "AZURE_CLIENT_SECRET",
214
+ }
215
+ _KEY_SKIP_SIGNATURE: ClassVar = "skip_signature"
216
+
217
+ @classmethod
218
+ def auto(cls) -> ABFS:
219
+ account_name = os.getenv(cls._KEY_ENV_VAR_MAPPING["account_name"], None)
220
+ account_key = os.getenv(cls._KEY_ENV_VAR_MAPPING["account_key"], None)
221
+ tenant_id = os.getenv(cls._KEY_ENV_VAR_MAPPING["tenant_id"], None)
222
+ client_id = os.getenv(cls._KEY_ENV_VAR_MAPPING["client_id"], None)
223
+ client_secret = os.getenv(cls._KEY_ENV_VAR_MAPPING["client_secret"], None)
224
+
225
+ kwargs: Dict[str, Any] = {}
226
+ kwargs = set_if_exists(kwargs, "account_name", account_name)
227
+ kwargs = set_if_exists(kwargs, "account_key", account_key)
228
+ kwargs = set_if_exists(kwargs, "tenant_id", tenant_id)
229
+ kwargs = set_if_exists(kwargs, "client_id", client_id)
230
+ kwargs = set_if_exists(kwargs, "client_secret", client_secret)
231
+ return ABFS(**kwargs)
232
+
233
+ def get_fsspec_kwargs(self, anonymous: bool = False, /, **kwargs) -> Dict[str, Any]:
234
+ config: Dict[str, Any] = {}
235
+ if "account_name" in kwargs or self.account_name:
236
+ config["account_name"] = kwargs.get("account_name", self.account_name)
237
+ if "account_key" in kwargs or self.account_key:
238
+ config["account_key"] = kwargs.get("account_key", self.account_key)
239
+ if "client_id" in kwargs or self.client_id:
240
+ config["client_id"] = kwargs.get("client_id", self.client_id)
241
+ if "client_secret" in kwargs or self.client_secret:
242
+ config["client_secret"] = kwargs.get("client_secret", self.client_secret)
243
+ if "tenant_id" in kwargs or self.tenant_id:
244
+ config["tenant_id"] = kwargs.get("tenant_id", self.tenant_id)
245
+
246
+ if anonymous:
247
+ config[self._KEY_SKIP_SIGNATURE] = True
248
+
249
+ client_options = {"timeout": "99999s", "allow_http": "true"}
250
+
251
+ if config:
252
+ kwargs["config"] = config
253
+ kwargs["client_options"] = client_options
254
+
255
+ return kwargs
256
+
257
+
258
+ @dataclass(init=True, repr=True, eq=True, frozen=True, kw_only=True)
259
+ class CommonInit:
260
+ """
261
+ Common initialization configuration for Flyte.
262
+ """
263
+
264
+ root_dir: Path
265
+ org: str | None = None
266
+ project: str | None = None
267
+ domain: str | None = None
268
+
269
+
270
+ @dataclass(init=True, kw_only=True, repr=True, eq=True, frozen=True)
271
+ class _InitConfig(CommonInit):
272
+ client: Optional[ClientSet] = None
273
+ storage: Optional[Storage] = None
274
+
275
+ def replace(self, **kwargs) -> _InitConfig:
276
+ return replace(self, **kwargs)
277
+
278
+
279
+ # Global singleton to store initialization configuration
280
+ _init_config: _InitConfig | None = None
281
+ _init_lock = threading.RLock() # Reentrant lock for thread safety
282
+
283
+
284
+ async def _initialize_client(
285
+ api_key: str | None = None,
286
+ auth_type: AuthType = "Pkce",
287
+ endpoint: str | None = None,
288
+ client_config: ClientConfig | None = None,
289
+ headless: bool = False,
290
+ insecure: bool = False,
291
+ insecure_skip_verify: bool = False,
292
+ ca_cert_file_path: str | None = None,
293
+ command: List[str] | None = None,
294
+ proxy_command: List[str] | None = None,
295
+ client_id: str | None = None,
296
+ client_credentials_secret: str | None = None,
297
+ rpc_retries: int = 3,
298
+ http_proxy_url: str | None = None,
299
+ ) -> ClientSet:
300
+ """
301
+ Initialize the client based on the execution mode.
302
+ :return: The initialized client
303
+ """
304
+ from flyte.remote._client.controlplane import ClientSet
305
+
306
+ if endpoint is not None:
307
+ return await ClientSet.for_endpoint(
308
+ endpoint,
309
+ insecure=insecure,
310
+ api_key=api_key,
311
+ insecure_skip_verify=insecure_skip_verify,
312
+ auth_type=auth_type,
313
+ headless=headless,
314
+ ca_cert_file_path=ca_cert_file_path,
315
+ command=command,
316
+ proxy_command=proxy_command,
317
+ client_id=client_id,
318
+ client_credentials_secret=client_credentials_secret,
319
+ client_config=client_config,
320
+ rpc_retries=rpc_retries,
321
+ http_proxy_url=http_proxy_url,
322
+ )
323
+ raise NotImplementedError("Currently only endpoints are supported.")
324
+
325
+
326
+ @syncer.wrap
327
+ async def init(
328
+ org: str | None = None,
329
+ project: str | None = None,
330
+ domain: str | None = None,
331
+ root_dir: Path | None = None,
332
+ log_level: int | None = None,
333
+ endpoint: str | None = None,
334
+ headless: bool = False,
335
+ insecure: bool = False,
336
+ insecure_skip_verify: bool = False,
337
+ ca_cert_file_path: str | None = None,
338
+ auth_type: AuthType = "Pkce",
339
+ command: List[str] | None = None,
340
+ proxy_command: List[str] | None = None,
341
+ api_key: str | None = None,
342
+ client_id: str | None = None,
343
+ client_credentials_secret: str | None = None,
344
+ auth_client_config: ClientConfig | None = None,
345
+ rpc_retries: int = 3,
346
+ http_proxy_url: str | None = None,
347
+ storage: Storage | None = None,
348
+ ) -> None:
349
+ """
350
+ Initialize the Flyte system with the given configuration. This method should be called before any other Flyte
351
+ remote API methods are called. Thread-safe implementation.
352
+
353
+ :param project: Optional project name (not used in this implementation)
354
+ :param domain: Optional domain name (not used in this implementation)
355
+ :param root_dir: Optional root directory from which to determine how to load files, and find paths to files.
356
+ defaults to the editable install directory if the cwd is in a Python editable install, else just the cwd.
357
+ :param log_level: Optional logging level for the logger, default is set using the default initialization policies
358
+ :param api_key: Optional API key for authentication
359
+ :param endpoint: Optional API endpoint URL
360
+ :param headless: Optional Whether to run in headless mode
361
+ :param mode: Optional execution model (local, remote). Default is local. When local is used,
362
+ the execution will be done locally. When remote is used, the execution will be sent to a remote server,
363
+ In the remote case, the endpoint or api_key must be set.
364
+ :param insecure_skip_verify: Whether to skip SSL certificate verification
365
+ :param auth_client_config: Optional client configuration for authentication
366
+ :param auth_type: The authentication type to use (Pkce, ClientSecret, ExternalCommand, DeviceFlow)
367
+ :param command: This command is executed to return a token using an external process
368
+ :param proxy_command: This command is executed to return a token for proxy authorization using an external process
369
+ :param client_id: This is the public identifier for the app which handles authorization for a Flyte deployment.
370
+ More details here: https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/.
371
+ :param client_credentials_secret: Used for service auth, which is automatically called during pyflyte. This will
372
+ allow the Flyte engine to read the password directly from the environment variable. Note that this is
373
+ less secure! Please only use this if mounting the secret as a file is impossible
374
+ :param ca_cert_file_path: [optional] str Root Cert to be loaded and used to verify admin
375
+ :param http_proxy_url: [optional] HTTP Proxy to be used for OAuth requests
376
+ :param rpc_retries: [optional] int Number of times to retry the platform calls
377
+ :param audience: oauth2 audience for the token request. This is used to validate the token
378
+ :param insecure: insecure flag for the client
379
+ :param storage: Optional blob store (S3, GCS, Azure) configuration if needed to access (i.e. using Minio)
380
+ :param org: Optional organization override for the client. Should be set by auth instead.
381
+
382
+ :return: None
383
+ """
384
+ from flyte._utils import get_cwd_editable_install
385
+
386
+ interactive_mode = ipython_check()
387
+
388
+ initialize_logger(enable_rich=interactive_mode)
389
+ if log_level:
390
+ initialize_logger(log_level=log_level, enable_rich=interactive_mode)
391
+
392
+ global _init_config # noqa: PLW0603
393
+
394
+ with _init_lock:
395
+ client = None
396
+ if endpoint or api_key:
397
+ client = await _initialize_client(
398
+ api_key=api_key,
399
+ auth_type=auth_type,
400
+ endpoint=endpoint,
401
+ headless=headless,
402
+ insecure=insecure,
403
+ insecure_skip_verify=insecure_skip_verify,
404
+ ca_cert_file_path=ca_cert_file_path,
405
+ command=command,
406
+ proxy_command=proxy_command,
407
+ client_id=client_id,
408
+ client_credentials_secret=client_credentials_secret,
409
+ client_config=auth_client_config,
410
+ rpc_retries=rpc_retries,
411
+ http_proxy_url=http_proxy_url,
412
+ )
413
+
414
+ root_dir = root_dir or get_cwd_editable_install() or Path.cwd()
415
+ _init_config = _InitConfig(
416
+ root_dir=root_dir,
417
+ project=project,
418
+ domain=domain,
419
+ client=client,
420
+ storage=storage,
421
+ org=org,
422
+ )
423
+
424
+
425
+ def _get_init_config() -> Optional[_InitConfig]:
426
+ """
427
+ Get the current initialization configuration. Thread-safe implementation.
428
+
429
+ :return: The current InitData if initialized, None otherwise
430
+ """
431
+ with _init_lock:
432
+ return _init_config
433
+
434
+
435
+ def get_common_config() -> CommonInit:
436
+ """
437
+ Get the current initialization configuration. Thread-safe implementation.
438
+
439
+ :return: The current InitData if initialized, None otherwise
440
+ """
441
+ cfg = _get_init_config()
442
+ if cfg is None:
443
+ raise InitializationError(
444
+ "StorageNotInitializedError",
445
+ "user",
446
+ "Configuration has not been initialized. Call flyte.init() with a valid endpoint or",
447
+ " api-key before using this function.",
448
+ )
449
+ return cfg
450
+
451
+
452
+ def get_storage() -> Storage:
453
+ """
454
+ Get the current storage configuration. Thread-safe implementation.
455
+
456
+ :return: The current storage configuration
457
+ """
458
+ cfg = _get_init_config()
459
+ if cfg is None:
460
+ raise InitializationError(
461
+ "StorageNotInitializedError",
462
+ "user",
463
+ "Configuration has not been initialized. Call flyte.init() with a valid endpoint or",
464
+ " api-key before using this function.",
465
+ )
466
+ if cfg.storage is None:
467
+ # return default local storage
468
+ return typing.cast(Storage, cfg.replace(storage=Storage()).storage)
469
+ return cfg.storage
470
+
471
+
472
+ def get_client() -> ClientSet:
473
+ """
474
+ Get the current client. Thread-safe implementation.
475
+
476
+ :return: The current client
477
+ """
478
+ cfg = _get_init_config()
479
+ if cfg is None or cfg.client is None:
480
+ raise InitializationError(
481
+ "ClientNotInitializedError",
482
+ "user",
483
+ "Client has not been initialized. Call flyte.init() with a valid endpoint or"
484
+ " api-key before using this function.",
485
+ )
486
+ return cfg.client
487
+
488
+
489
+ def is_initialized() -> bool:
490
+ """
491
+ Check if the system has been initialized.
492
+
493
+ :return: True if initialized, False otherwise
494
+ """
495
+ return _get_init_config() is not None
496
+
497
+
498
+ def initialize_in_cluster(storage: Storage | None = None) -> None:
499
+ """
500
+ Initialize the system for in-cluster execution. This is a placeholder function and does not perform any actions.
501
+
502
+ :return: None
503
+ """
504
+ init(storage=storage)
505
+
506
+
507
+ # Define a generic type variable for the decorated function
508
+ T = TypeVar("T", bound=Callable)
509
+
510
+
511
+ def requires_client(func: T) -> T:
512
+ """
513
+ Decorator that checks if the client has been initialized before executing the function.
514
+ Raises InitializationError if the client is not initialized.
515
+
516
+ :param func: Function to decorate
517
+ :return: Decorated function that checks for initialization
518
+ """
519
+
520
+ @functools.wraps(func)
521
+ def wrapper(*args, **kwargs) -> T:
522
+ init_config = _get_init_config()
523
+ if init_config is None or init_config.client is None:
524
+ raise InitializationError(
525
+ "ClientNotInitializedError",
526
+ "user",
527
+ f"Function '{func.__name__}' requires client to be initialized. "
528
+ f"Call flyte.init() with a valid endpoint or api-key before using this function.",
529
+ )
530
+ return func(*args, **kwargs)
531
+
532
+ return typing.cast(T, wrapper)
533
+
534
+
535
+ def requires_storage(func: T) -> T:
536
+ """
537
+ Decorator that checks if the storage has been initialized before executing the function.
538
+ Raises InitializationError if the storage is not initialized.
539
+
540
+ :param func: Function to decorate
541
+ :return: Decorated function that checks for initialization
542
+ """
543
+
544
+ @functools.wraps(func)
545
+ def wrapper(*args, **kwargs):
546
+ if _get_init_config() is None or _get_init_config().storage is None:
547
+ raise InitializationError(
548
+ "StorageNotInitializedError",
549
+ "user",
550
+ f"Function '{func.__name__}' requires storage to be initialized. "
551
+ f"Call flyte.init() with a valid storage configuration before using this function.",
552
+ )
553
+ return func(*args, **kwargs)
554
+
555
+ return typing.cast(T, wrapper)
556
+
557
+
558
+ def requires_upload_location(func: T) -> T:
559
+ """
560
+ Decorator that checks if the storage has been initialized before executing the function.
561
+ Raises InitializationError if the storage is not initialized.
562
+
563
+ :param func: Function to decorate
564
+ :return: Decorated function that checks for initialization
565
+ """
566
+
567
+ @functools.wraps(func)
568
+ def wrapper(*args, **kwargs) -> T:
569
+ from ._context import internal_ctx
570
+
571
+ ctx = internal_ctx()
572
+ if not ctx.raw_data:
573
+ raise InitializationError(
574
+ "No upload path configured",
575
+ "user",
576
+ f"Function '{func.__name__}' requires client to be initialized. "
577
+ f"Call flyte.init() with storage configuration before using this function.",
578
+ )
579
+ return func(*args, **kwargs)
580
+
581
+ return typing.cast(T, wrapper)
582
+
583
+
584
+ def requires_initialization(func: T) -> T:
585
+ """
586
+ Decorator that checks if the system has been initialized before executing the function.
587
+ Raises InitializationError if the system is not initialized.
588
+
589
+ :param func: Function to decorate
590
+ :return: Decorated function that checks for initialization
591
+ """
592
+
593
+ @functools.wraps(func)
594
+ def wrapper(*args, **kwargs) -> T:
595
+ if not is_initialized():
596
+ raise InitializationError(
597
+ "NotInitConfiguredError",
598
+ "user",
599
+ f"Function '{func.__name__}' requires initialization. Call flyte.init() before using this function.",
600
+ )
601
+ return func(*args, **kwargs)
602
+
603
+ return typing.cast(T, wrapper)
604
+
605
+
606
+ async def _init_for_testing(
607
+ project: str | None = None,
608
+ domain: str | None = None,
609
+ root_dir: Path | None = None,
610
+ log_level: int | None = None,
611
+ client: ClientSet | None = None,
612
+ ):
613
+ from flyte._utils.helpers import get_cwd_editable_install
614
+
615
+ global _init_config # noqa: PLW0603
616
+
617
+ if log_level:
618
+ initialize_logger(log_level=log_level)
619
+
620
+ with _init_lock:
621
+ root_dir = root_dir or get_cwd_editable_install() or Path.cwd()
622
+ _init_config = _InitConfig(
623
+ root_dir=root_dir,
624
+ project=project,
625
+ domain=domain,
626
+ client=client,
627
+ )
628
+
629
+
630
+ def replace_client(client):
631
+ global _init_config # noqa: PLW0603
632
+
633
+ with _init_lock:
634
+ _init_config = _init_config.replace(client=client)