toil 7.0.0__py3-none-any.whl → 8.1.0b1__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.
Files changed (197) hide show
  1. toil/__init__.py +124 -86
  2. toil/batchSystems/__init__.py +1 -0
  3. toil/batchSystems/abstractBatchSystem.py +137 -77
  4. toil/batchSystems/abstractGridEngineBatchSystem.py +211 -101
  5. toil/batchSystems/awsBatch.py +237 -128
  6. toil/batchSystems/cleanup_support.py +22 -16
  7. toil/batchSystems/contained_executor.py +30 -26
  8. toil/batchSystems/gridengine.py +85 -49
  9. toil/batchSystems/htcondor.py +164 -87
  10. toil/batchSystems/kubernetes.py +622 -386
  11. toil/batchSystems/local_support.py +17 -12
  12. toil/batchSystems/lsf.py +132 -79
  13. toil/batchSystems/lsfHelper.py +13 -11
  14. toil/batchSystems/mesos/__init__.py +41 -29
  15. toil/batchSystems/mesos/batchSystem.py +288 -149
  16. toil/batchSystems/mesos/executor.py +77 -49
  17. toil/batchSystems/mesos/test/__init__.py +31 -23
  18. toil/batchSystems/options.py +39 -29
  19. toil/batchSystems/registry.py +53 -19
  20. toil/batchSystems/singleMachine.py +293 -123
  21. toil/batchSystems/slurm.py +651 -155
  22. toil/batchSystems/torque.py +46 -32
  23. toil/bus.py +141 -73
  24. toil/common.py +784 -397
  25. toil/cwl/__init__.py +1 -1
  26. toil/cwl/cwltoil.py +1137 -534
  27. toil/cwl/utils.py +17 -22
  28. toil/deferred.py +62 -41
  29. toil/exceptions.py +5 -3
  30. toil/fileStores/__init__.py +5 -5
  31. toil/fileStores/abstractFileStore.py +88 -57
  32. toil/fileStores/cachingFileStore.py +711 -247
  33. toil/fileStores/nonCachingFileStore.py +113 -75
  34. toil/job.py +1031 -349
  35. toil/jobStores/abstractJobStore.py +387 -243
  36. toil/jobStores/aws/jobStore.py +772 -412
  37. toil/jobStores/aws/utils.py +161 -109
  38. toil/jobStores/conftest.py +1 -0
  39. toil/jobStores/fileJobStore.py +289 -151
  40. toil/jobStores/googleJobStore.py +137 -70
  41. toil/jobStores/utils.py +36 -15
  42. toil/leader.py +614 -269
  43. toil/lib/accelerators.py +115 -18
  44. toil/lib/aws/__init__.py +55 -28
  45. toil/lib/aws/ami.py +122 -87
  46. toil/lib/aws/iam.py +284 -108
  47. toil/lib/aws/s3.py +31 -0
  48. toil/lib/aws/session.py +204 -58
  49. toil/lib/aws/utils.py +290 -213
  50. toil/lib/bioio.py +13 -5
  51. toil/lib/compatibility.py +11 -6
  52. toil/lib/conversions.py +83 -49
  53. toil/lib/docker.py +131 -103
  54. toil/lib/dockstore.py +379 -0
  55. toil/lib/ec2.py +322 -209
  56. toil/lib/ec2nodes.py +174 -105
  57. toil/lib/encryption/_dummy.py +5 -3
  58. toil/lib/encryption/_nacl.py +10 -6
  59. toil/lib/encryption/conftest.py +1 -0
  60. toil/lib/exceptions.py +26 -7
  61. toil/lib/expando.py +4 -2
  62. toil/lib/ftp_utils.py +217 -0
  63. toil/lib/generatedEC2Lists.py +127 -19
  64. toil/lib/history.py +1271 -0
  65. toil/lib/history_submission.py +681 -0
  66. toil/lib/humanize.py +6 -2
  67. toil/lib/io.py +121 -12
  68. toil/lib/iterables.py +4 -2
  69. toil/lib/memoize.py +12 -8
  70. toil/lib/misc.py +83 -18
  71. toil/lib/objects.py +2 -2
  72. toil/lib/resources.py +19 -7
  73. toil/lib/retry.py +125 -87
  74. toil/lib/threading.py +282 -80
  75. toil/lib/throttle.py +15 -14
  76. toil/lib/trs.py +390 -0
  77. toil/lib/web.py +38 -0
  78. toil/options/common.py +850 -402
  79. toil/options/cwl.py +185 -90
  80. toil/options/runner.py +50 -0
  81. toil/options/wdl.py +70 -19
  82. toil/provisioners/__init__.py +111 -46
  83. toil/provisioners/abstractProvisioner.py +322 -157
  84. toil/provisioners/aws/__init__.py +62 -30
  85. toil/provisioners/aws/awsProvisioner.py +980 -627
  86. toil/provisioners/clusterScaler.py +541 -279
  87. toil/provisioners/gceProvisioner.py +283 -180
  88. toil/provisioners/node.py +147 -79
  89. toil/realtimeLogger.py +34 -22
  90. toil/resource.py +137 -75
  91. toil/server/app.py +127 -61
  92. toil/server/celery_app.py +3 -1
  93. toil/server/cli/wes_cwl_runner.py +84 -55
  94. toil/server/utils.py +56 -31
  95. toil/server/wes/abstract_backend.py +64 -26
  96. toil/server/wes/amazon_wes_utils.py +21 -15
  97. toil/server/wes/tasks.py +121 -63
  98. toil/server/wes/toil_backend.py +142 -107
  99. toil/server/wsgi_app.py +4 -3
  100. toil/serviceManager.py +58 -22
  101. toil/statsAndLogging.py +183 -65
  102. toil/test/__init__.py +263 -179
  103. toil/test/batchSystems/batchSystemTest.py +438 -195
  104. toil/test/batchSystems/batch_system_plugin_test.py +18 -7
  105. toil/test/batchSystems/test_gridengine.py +173 -0
  106. toil/test/batchSystems/test_lsf_helper.py +67 -58
  107. toil/test/batchSystems/test_slurm.py +265 -49
  108. toil/test/cactus/test_cactus_integration.py +20 -22
  109. toil/test/cwl/conftest.py +39 -0
  110. toil/test/cwl/cwlTest.py +375 -72
  111. toil/test/cwl/measure_default_memory.cwl +12 -0
  112. toil/test/cwl/not_run_required_input.cwl +29 -0
  113. toil/test/cwl/optional-file.cwl +18 -0
  114. toil/test/cwl/scatter_duplicate_outputs.cwl +40 -0
  115. toil/test/docs/scriptsTest.py +60 -34
  116. toil/test/jobStores/jobStoreTest.py +412 -235
  117. toil/test/lib/aws/test_iam.py +116 -48
  118. toil/test/lib/aws/test_s3.py +16 -9
  119. toil/test/lib/aws/test_utils.py +5 -6
  120. toil/test/lib/dockerTest.py +118 -141
  121. toil/test/lib/test_conversions.py +113 -115
  122. toil/test/lib/test_ec2.py +57 -49
  123. toil/test/lib/test_history.py +212 -0
  124. toil/test/lib/test_misc.py +12 -5
  125. toil/test/lib/test_trs.py +161 -0
  126. toil/test/mesos/MesosDataStructuresTest.py +23 -10
  127. toil/test/mesos/helloWorld.py +7 -6
  128. toil/test/mesos/stress.py +25 -20
  129. toil/test/options/options.py +7 -2
  130. toil/test/provisioners/aws/awsProvisionerTest.py +293 -140
  131. toil/test/provisioners/clusterScalerTest.py +440 -250
  132. toil/test/provisioners/clusterTest.py +81 -42
  133. toil/test/provisioners/gceProvisionerTest.py +174 -100
  134. toil/test/provisioners/provisionerTest.py +25 -13
  135. toil/test/provisioners/restartScript.py +5 -4
  136. toil/test/server/serverTest.py +188 -141
  137. toil/test/sort/restart_sort.py +137 -68
  138. toil/test/sort/sort.py +134 -66
  139. toil/test/sort/sortTest.py +91 -49
  140. toil/test/src/autoDeploymentTest.py +140 -100
  141. toil/test/src/busTest.py +20 -18
  142. toil/test/src/checkpointTest.py +8 -2
  143. toil/test/src/deferredFunctionTest.py +49 -35
  144. toil/test/src/dockerCheckTest.py +33 -26
  145. toil/test/src/environmentTest.py +20 -10
  146. toil/test/src/fileStoreTest.py +538 -271
  147. toil/test/src/helloWorldTest.py +7 -4
  148. toil/test/src/importExportFileTest.py +61 -31
  149. toil/test/src/jobDescriptionTest.py +32 -17
  150. toil/test/src/jobEncapsulationTest.py +2 -0
  151. toil/test/src/jobFileStoreTest.py +74 -50
  152. toil/test/src/jobServiceTest.py +187 -73
  153. toil/test/src/jobTest.py +120 -70
  154. toil/test/src/miscTests.py +19 -18
  155. toil/test/src/promisedRequirementTest.py +82 -36
  156. toil/test/src/promisesTest.py +7 -6
  157. toil/test/src/realtimeLoggerTest.py +6 -6
  158. toil/test/src/regularLogTest.py +71 -37
  159. toil/test/src/resourceTest.py +80 -49
  160. toil/test/src/restartDAGTest.py +36 -22
  161. toil/test/src/resumabilityTest.py +9 -2
  162. toil/test/src/retainTempDirTest.py +45 -14
  163. toil/test/src/systemTest.py +12 -8
  164. toil/test/src/threadingTest.py +44 -25
  165. toil/test/src/toilContextManagerTest.py +10 -7
  166. toil/test/src/userDefinedJobArgTypeTest.py +8 -5
  167. toil/test/src/workerTest.py +33 -16
  168. toil/test/utils/toilDebugTest.py +70 -58
  169. toil/test/utils/toilKillTest.py +4 -5
  170. toil/test/utils/utilsTest.py +239 -102
  171. toil/test/wdl/wdltoil_test.py +789 -148
  172. toil/test/wdl/wdltoil_test_kubernetes.py +37 -23
  173. toil/toilState.py +52 -26
  174. toil/utils/toilConfig.py +13 -4
  175. toil/utils/toilDebugFile.py +44 -27
  176. toil/utils/toilDebugJob.py +85 -25
  177. toil/utils/toilDestroyCluster.py +11 -6
  178. toil/utils/toilKill.py +8 -3
  179. toil/utils/toilLaunchCluster.py +251 -145
  180. toil/utils/toilMain.py +37 -16
  181. toil/utils/toilRsyncCluster.py +27 -14
  182. toil/utils/toilSshCluster.py +45 -22
  183. toil/utils/toilStats.py +75 -36
  184. toil/utils/toilStatus.py +226 -119
  185. toil/utils/toilUpdateEC2Instances.py +3 -1
  186. toil/version.py +6 -6
  187. toil/wdl/utils.py +5 -5
  188. toil/wdl/wdltoil.py +3528 -1053
  189. toil/worker.py +370 -149
  190. toil-8.1.0b1.dist-info/METADATA +178 -0
  191. toil-8.1.0b1.dist-info/RECORD +259 -0
  192. {toil-7.0.0.dist-info → toil-8.1.0b1.dist-info}/WHEEL +1 -1
  193. toil-7.0.0.dist-info/METADATA +0 -158
  194. toil-7.0.0.dist-info/RECORD +0 -244
  195. {toil-7.0.0.dist-info → toil-8.1.0b1.dist-info}/LICENSE +0 -0
  196. {toil-7.0.0.dist-info → toil-8.1.0b1.dist-info}/entry_points.txt +0 -0
  197. {toil-7.0.0.dist-info → toil-8.1.0b1.dist-info}/top_level.txt +0 -0
toil/lib/aws/session.py CHANGED
@@ -15,7 +15,7 @@ import collections
15
15
  import logging
16
16
  import os
17
17
  import threading
18
- from typing import Dict, Optional, Tuple, cast, Union, Literal, overload, TypeVar
18
+ from typing import TYPE_CHECKING, Literal, Optional, cast, overload
19
19
 
20
20
  import boto3
21
21
  import boto3.resources.base
@@ -24,15 +24,20 @@ from boto3 import Session
24
24
  from botocore.client import Config
25
25
  from botocore.session import get_session
26
26
  from botocore.utils import JSONFileCache
27
- from mypy_boto3_autoscaling import AutoScalingClient
28
- from mypy_boto3_ec2 import EC2Client, EC2ServiceResource
29
- from mypy_boto3_iam import IAMClient, IAMServiceResource
30
- from mypy_boto3_s3 import S3Client, S3ServiceResource
31
- from mypy_boto3_sdb import SimpleDBClient
32
- from mypy_boto3_sts import STSClient
27
+
28
+ if TYPE_CHECKING:
29
+ from mypy_boto3_autoscaling import AutoScalingClient
30
+ from mypy_boto3_ec2 import EC2Client, EC2ServiceResource
31
+ from mypy_boto3_iam import IAMClient, IAMServiceResource
32
+ from mypy_boto3_s3 import S3Client, S3ServiceResource
33
+ from mypy_boto3_sdb import SimpleDBClient
34
+ from mypy_boto3_sts import STSClient
33
35
 
34
36
  logger = logging.getLogger(__name__)
35
37
 
38
+ # You can pass config=ANONYMOUS_CONFIG to make anonymous S3 accesses
39
+ ANONYMOUS_CONFIG = Config(signature_version=botocore.UNSIGNED)
40
+
36
41
  # A note on thread safety:
37
42
  #
38
43
  # Boto3 Session: Not thread safe, 1 per thread is required.
@@ -49,6 +54,7 @@ logger = logging.getLogger(__name__)
49
54
  # initializing Boto3 (or Boto2) things at a time.
50
55
  _init_lock = threading.RLock()
51
56
 
57
+
52
58
  def _new_boto3_session(region_name: Optional[str] = None) -> Session:
53
59
  """
54
60
  This is the One True Place where new Boto3 sessions should be made, and
@@ -64,10 +70,16 @@ def _new_boto3_session(region_name: Optional[str] = None) -> Session:
64
70
 
65
71
  with _init_lock:
66
72
  botocore_session = get_session()
67
- botocore_session.get_component('credential_provider').get_provider(
68
- 'assume-role').cache = JSONFileCache()
73
+ botocore_session.get_component("credential_provider").get_provider(
74
+ "assume-role"
75
+ ).cache = JSONFileCache()
76
+
77
+ return Session(
78
+ botocore_session=botocore_session,
79
+ region_name=region_name,
80
+ profile_name=os.environ.get("TOIL_AWS_PROFILE", None),
81
+ )
69
82
 
70
- return Session(botocore_session=botocore_session, region_name=region_name, profile_name=os.environ.get("TOIL_AWS_PROFILE", None))
71
83
 
72
84
  class AWSConnectionManager:
73
85
  """
@@ -103,36 +115,68 @@ class AWSConnectionManager:
103
115
  """
104
116
  # This stores Boto3 sessions in .item of a thread-local storage, by
105
117
  # region.
106
- self.sessions_by_region: Dict[Optional[str], threading.local] = collections.defaultdict(threading.local)
118
+ self.sessions_by_region: dict[Optional[str], threading.local] = (
119
+ collections.defaultdict(threading.local)
120
+ )
107
121
  # This stores Boto3 resources in .item of a thread-local storage, by
108
122
  # (region, service name, endpoint URL) tuples
109
- self.resource_cache: Dict[Tuple[Optional[str], str, Optional[str]], threading.local] = collections.defaultdict(threading.local)
123
+ self.resource_cache: dict[
124
+ tuple[Optional[str], str, Optional[str]], threading.local
125
+ ] = collections.defaultdict(threading.local)
110
126
  # This stores Boto3 clients in .item of a thread-local storage, by
111
127
  # (region, service name, endpoint URL) tuples
112
- self.client_cache: Dict[Tuple[Optional[str], str, Optional[str]], threading.local] = collections.defaultdict(threading.local)
128
+ self.client_cache: dict[
129
+ tuple[Optional[str], str, Optional[str]], threading.local
130
+ ] = collections.defaultdict(threading.local)
113
131
  # This stores Boto 2 connections in .item of a thread-local storage, by
114
132
  # (region, service name) tuples.
115
- self.boto2_cache: Dict[Tuple[Optional[str], str], threading.local] = collections.defaultdict(threading.local)
133
+ self.boto2_cache: dict[tuple[Optional[str], str], threading.local] = (
134
+ collections.defaultdict(threading.local)
135
+ )
116
136
 
117
137
  def session(self, region: Optional[str]) -> boto3.session.Session:
118
138
  """
119
139
  Get the Boto3 Session to use for the given region.
120
140
  """
121
141
  storage = self.sessions_by_region[region]
122
- if not hasattr(storage, 'item'):
142
+ if not hasattr(storage, "item"):
123
143
  # This is the first time this thread wants to talk to this region
124
144
  # through this manager
125
145
  storage.item = _new_boto3_session(region_name=region)
126
146
  return cast(boto3.session.Session, storage.item)
127
147
 
128
148
  @overload
129
- def resource(self, region: Optional[str], service_name: Literal["s3"], endpoint_url: Optional[str] = None) -> S3ServiceResource: ...
149
+ def resource(
150
+ self,
151
+ region: Optional[str],
152
+ service_name: Literal["s3"],
153
+ endpoint_url: Optional[str] = None,
154
+ config: Optional[Config] = None,
155
+ ) -> "S3ServiceResource": ...
130
156
  @overload
131
- def resource(self, region: Optional[str], service_name: Literal["iam"], endpoint_url: Optional[str] = None) -> IAMServiceResource: ...
157
+ def resource(
158
+ self,
159
+ region: Optional[str],
160
+ service_name: Literal["iam"],
161
+ endpoint_url: Optional[str] = None,
162
+ config: Optional[Config] = None,
163
+ ) -> "IAMServiceResource": ...
132
164
  @overload
133
- def resource(self, region: Optional[str], service_name: Literal["ec2"], endpoint_url: Optional[str] = None) -> EC2ServiceResource: ...
134
-
135
- def resource(self, region: Optional[str], service_name: str, endpoint_url: Optional[str] = None) -> boto3.resources.base.ServiceResource:
165
+ def resource(
166
+ self,
167
+ region: Optional[str],
168
+ service_name: Literal["ec2"],
169
+ endpoint_url: Optional[str] = None,
170
+ config: Optional[Config] = None,
171
+ ) -> "EC2ServiceResource": ...
172
+
173
+ def resource(
174
+ self,
175
+ region: Optional[str],
176
+ service_name: str,
177
+ endpoint_url: Optional[str] = None,
178
+ config: Optional[Config] = None,
179
+ ) -> boto3.resources.base.ServiceResource:
136
180
  """
137
181
  Get the Boto3 Resource to use with the given service (like 'ec2') in the given region.
138
182
 
@@ -141,7 +185,7 @@ class AWSConnectionManager:
141
185
  """
142
186
  key = (region, service_name, endpoint_url)
143
187
  storage = self.resource_cache[key]
144
- if not hasattr(storage, 'item'):
188
+ if not hasattr(storage, "item"):
145
189
  with _init_lock:
146
190
  # We lock inside the if check; we don't care if the memoization
147
191
  # sometimes results in multiple different copies leaking out.
@@ -151,35 +195,69 @@ class AWSConnectionManager:
151
195
  # The Boto3 stubs are missing an overload for `resource` that takes
152
196
  # a non-literal string. See
153
197
  # <https://github.com/vemel/mypy_boto3_builder/issues/121#issuecomment-1011322636>
154
- storage.item = self.session(region).resource(service_name, endpoint_url=endpoint_url) # type: ignore
198
+ storage.item = self.session(region).resource(service_name, endpoint_url=endpoint_url, config=config) # type: ignore
155
199
  else:
156
200
  # We might not be able to pass None to Boto3 and have it be the same as no argument.
157
- storage.item = self.session(region).resource(service_name) # type: ignore
201
+ storage.item = self.session(region).resource(service_name, config=config) # type: ignore
158
202
 
159
203
  return cast(boto3.resources.base.ServiceResource, storage.item)
160
204
 
161
205
  @overload
162
- def client(self, region: Optional[str], service_name: Literal["ec2"], endpoint_url: Optional[str] = None,
163
- config: Optional[Config] = None) -> EC2Client: ...
206
+ def client(
207
+ self,
208
+ region: Optional[str],
209
+ service_name: Literal["ec2"],
210
+ endpoint_url: Optional[str] = None,
211
+ config: Optional[Config] = None,
212
+ ) -> "EC2Client": ...
164
213
  @overload
165
- def client(self, region: Optional[str], service_name: Literal["iam"], endpoint_url: Optional[str] = None,
166
- config: Optional[Config] = None) -> IAMClient: ...
214
+ def client(
215
+ self,
216
+ region: Optional[str],
217
+ service_name: Literal["iam"],
218
+ endpoint_url: Optional[str] = None,
219
+ config: Optional[Config] = None,
220
+ ) -> "IAMClient": ...
167
221
  @overload
168
- def client(self, region: Optional[str], service_name: Literal["s3"], endpoint_url: Optional[str] = None,
169
- config: Optional[Config] = None) -> S3Client: ...
222
+ def client(
223
+ self,
224
+ region: Optional[str],
225
+ service_name: Literal["s3"],
226
+ endpoint_url: Optional[str] = None,
227
+ config: Optional[Config] = None,
228
+ ) -> "S3Client": ...
170
229
  @overload
171
- def client(self, region: Optional[str], service_name: Literal["sts"], endpoint_url: Optional[str] = None,
172
- config: Optional[Config] = None) -> STSClient: ...
230
+ def client(
231
+ self,
232
+ region: Optional[str],
233
+ service_name: Literal["sts"],
234
+ endpoint_url: Optional[str] = None,
235
+ config: Optional[Config] = None,
236
+ ) -> "STSClient": ...
173
237
  @overload
174
- def client(self, region: Optional[str], service_name: Literal["sdb"], endpoint_url: Optional[str] = None,
175
- config: Optional[Config] = None) -> SimpleDBClient: ...
238
+ def client(
239
+ self,
240
+ region: Optional[str],
241
+ service_name: Literal["sdb"],
242
+ endpoint_url: Optional[str] = None,
243
+ config: Optional[Config] = None,
244
+ ) -> "SimpleDBClient": ...
176
245
  @overload
177
- def client(self, region: Optional[str], service_name: Literal["autoscaling"], endpoint_url: Optional[str] = None,
178
- config: Optional[Config] = None) -> AutoScalingClient: ...
179
-
180
-
181
- def client(self, region: Optional[str], service_name: Literal["ec2", "iam", "s3", "sts", "sdb", "autoscaling"], endpoint_url: Optional[str] = None,
182
- config: Optional[Config] = None) -> botocore.client.BaseClient:
246
+ def client(
247
+ self,
248
+ region: Optional[str],
249
+ service_name: Literal["autoscaling"],
250
+ endpoint_url: Optional[str] = None,
251
+ config: Optional[Config] = None,
252
+ ) -> "AutoScalingClient": ...
253
+
254
+ def client(
255
+ self,
256
+ region: Optional[str],
257
+ service_name: Literal["ec2", "iam", "s3", "sts", "sdb", "autoscaling"],
258
+ endpoint_url: Optional[str] = None,
259
+ config: Optional[Config] = None,
260
+ ) -> botocore.client.BaseClient:
183
261
  """
184
262
  Get the Boto3 Client to use with the given service (like 'ec2') in the given region.
185
263
 
@@ -192,29 +270,34 @@ class AWSConnectionManager:
192
270
  # Don't try and memoize if a custom config is used
193
271
  with _init_lock:
194
272
  if endpoint_url is not None:
195
- return self.session(region).client(service_name, endpoint_url=endpoint_url, config=config)
273
+ return self.session(region).client(
274
+ service_name, endpoint_url=endpoint_url, config=config
275
+ )
196
276
  else:
197
277
  return self.session(region).client(service_name, config=config)
198
278
 
199
279
  key = (region, service_name, endpoint_url)
200
280
  storage = self.client_cache[key]
201
- if not hasattr(storage, 'item'):
281
+ if not hasattr(storage, "item"):
202
282
  with _init_lock:
203
283
  # We lock because we call .client()
204
284
 
205
285
  if endpoint_url is not None:
206
286
  # The Boto3 stubs are probably missing an overload here too. See:
207
287
  # <https://github.com/vemel/mypy_boto3_builder/issues/121#issuecomment-1011322636>
208
- storage.item = self.session(region).client(service_name, endpoint_url=endpoint_url)
288
+ storage.item = self.session(region).client(
289
+ service_name, endpoint_url=endpoint_url
290
+ )
209
291
  else:
210
292
  # We might not be able to pass None to Boto3 and have it be the same as no argument.
211
293
  storage.item = self.session(region).client(service_name)
212
- return cast(botocore.client.BaseClient , storage.item)
294
+ return cast(botocore.client.BaseClient, storage.item)
213
295
 
214
296
 
215
297
  # If you don't want your own AWSConnectionManager, we have a global one and some global functions
216
298
  _global_manager = AWSConnectionManager()
217
299
 
300
+
218
301
  def establish_boto3_session(region_name: Optional[str] = None) -> Session:
219
302
  """
220
303
  Get a Boto 3 session usable by the current thread.
@@ -225,20 +308,57 @@ def establish_boto3_session(region_name: Optional[str] = None) -> Session:
225
308
  # Just use a global version of the manager. Note that we change the argument order!
226
309
  return _global_manager.session(region_name)
227
310
 
311
+
228
312
  @overload
229
- def client(service_name: Literal["ec2"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None, config: Optional[Config] = None) -> EC2Client: ...
313
+ def client(
314
+ service_name: Literal["ec2"],
315
+ region_name: Optional[str] = None,
316
+ endpoint_url: Optional[str] = None,
317
+ config: Optional[Config] = None,
318
+ ) -> "EC2Client": ...
230
319
  @overload
231
- def client(service_name: Literal["iam"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None, config: Optional[Config] = None) -> IAMClient: ...
320
+ def client(
321
+ service_name: Literal["iam"],
322
+ region_name: Optional[str] = None,
323
+ endpoint_url: Optional[str] = None,
324
+ config: Optional[Config] = None,
325
+ ) -> "IAMClient": ...
232
326
  @overload
233
- def client(service_name: Literal["s3"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None, config: Optional[Config] = None) -> S3Client: ...
327
+ def client(
328
+ service_name: Literal["s3"],
329
+ region_name: Optional[str] = None,
330
+ endpoint_url: Optional[str] = None,
331
+ config: Optional[Config] = None,
332
+ ) -> "S3Client": ...
234
333
  @overload
235
- def client(service_name: Literal["sts"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None, config: Optional[Config] = None) -> STSClient: ...
334
+ def client(
335
+ service_name: Literal["sts"],
336
+ region_name: Optional[str] = None,
337
+ endpoint_url: Optional[str] = None,
338
+ config: Optional[Config] = None,
339
+ ) -> "STSClient": ...
236
340
  @overload
237
- def client(service_name: Literal["sdb"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None, config: Optional[Config] = None) -> SimpleDBClient: ...
341
+ def client(
342
+ service_name: Literal["sdb"],
343
+ region_name: Optional[str] = None,
344
+ endpoint_url: Optional[str] = None,
345
+ config: Optional[Config] = None,
346
+ ) -> "SimpleDBClient": ...
238
347
  @overload
239
- def client(service_name: Literal["autoscaling"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None, config: Optional[Config] = None) -> AutoScalingClient: ...
240
-
241
- def client(service_name: Literal["ec2", "iam", "s3", "sts", "sdb", "autoscaling"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None, config: Optional[Config] = None) -> botocore.client.BaseClient:
348
+ def client(
349
+ service_name: Literal["autoscaling"],
350
+ region_name: Optional[str] = None,
351
+ endpoint_url: Optional[str] = None,
352
+ config: Optional[Config] = None,
353
+ ) -> "AutoScalingClient": ...
354
+
355
+
356
+ def client(
357
+ service_name: Literal["ec2", "iam", "s3", "sts", "sdb", "autoscaling"],
358
+ region_name: Optional[str] = None,
359
+ endpoint_url: Optional[str] = None,
360
+ config: Optional[Config] = None,
361
+ ) -> botocore.client.BaseClient:
242
362
  """
243
363
  Get a Boto 3 client for a particular AWS service, usable by the current thread.
244
364
 
@@ -246,16 +366,40 @@ def client(service_name: Literal["ec2", "iam", "s3", "sts", "sdb", "autoscaling"
246
366
  """
247
367
 
248
368
  # Just use a global version of the manager. Note that we change the argument order!
249
- return _global_manager.client(region_name, service_name, endpoint_url=endpoint_url, config=config)
369
+ return _global_manager.client(
370
+ region_name, service_name, endpoint_url=endpoint_url, config=config
371
+ )
372
+
250
373
 
251
374
  @overload
252
- def resource(service_name: Literal["s3"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None) -> S3ServiceResource: ...
375
+ def resource(
376
+ service_name: Literal["s3"],
377
+ region_name: Optional[str] = None,
378
+ endpoint_url: Optional[str] = None,
379
+ config: Optional[Config] = None,
380
+ ) -> "S3ServiceResource": ...
253
381
  @overload
254
- def resource(service_name: Literal["iam"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None) -> IAMServiceResource: ...
382
+ def resource(
383
+ service_name: Literal["iam"],
384
+ region_name: Optional[str] = None,
385
+ endpoint_url: Optional[str] = None,
386
+ config: Optional[Config] = None,
387
+ ) -> "IAMServiceResource": ...
255
388
  @overload
256
- def resource(service_name: Literal["ec2"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None) -> EC2ServiceResource: ...
257
-
258
- def resource(service_name: Literal["s3", "iam", "ec2"], region_name: Optional[str] = None, endpoint_url: Optional[str] = None) -> boto3.resources.base.ServiceResource:
389
+ def resource(
390
+ service_name: Literal["ec2"],
391
+ region_name: Optional[str] = None,
392
+ endpoint_url: Optional[str] = None,
393
+ config: Optional[Config] = None,
394
+ ) -> "EC2ServiceResource": ...
395
+
396
+
397
+ def resource(
398
+ service_name: Literal["s3", "iam", "ec2"],
399
+ region_name: Optional[str] = None,
400
+ endpoint_url: Optional[str] = None,
401
+ config: Optional[Config] = None,
402
+ ) -> boto3.resources.base.ServiceResource:
259
403
  """
260
404
  Get a Boto 3 resource for a particular AWS service, usable by the current thread.
261
405
 
@@ -263,4 +407,6 @@ def resource(service_name: Literal["s3", "iam", "ec2"], region_name: Optional[st
263
407
  """
264
408
 
265
409
  # Just use a global version of the manager. Note that we change the argument order!
266
- return _global_manager.resource(region_name, service_name, endpoint_url=endpoint_url)
410
+ return _global_manager.resource(
411
+ region_name, service_name, endpoint_url=endpoint_url, config=config
412
+ )