Skip to content

Commit d54edda

Browse files
committed
get rid of inline imports
1 parent 5ba50dd commit d54edda

File tree

4 files changed

+146
-84
lines changed

4 files changed

+146
-84
lines changed

src/apify_client/_apify_client.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@
5151
ScheduleClientAsync,
5252
ScheduleCollectionClient,
5353
ScheduleCollectionClientAsync,
54+
StatusMessageWatcherAsync,
55+
StatusMessageWatcherSync,
5456
StoreCollectionClient,
5557
StoreCollectionClientAsync,
58+
StreamedLogAsync,
59+
StreamedLogSync,
5660
TaskClient,
5761
TaskClientAsync,
5862
TaskCollectionClient,
@@ -124,21 +128,34 @@ def __init__(
124128

125129
self._client_registry = ClientRegistry(
126130
actor_client=ActorClient,
127-
actor_version_client=ActorVersionClient,
128-
actor_version_collection_client=ActorVersionCollectionClient,
131+
actor_collection_client=ActorCollectionClient,
129132
actor_env_var_client=ActorEnvVarClient,
130133
actor_env_var_collection_client=ActorEnvVarCollectionClient,
134+
actor_version_client=ActorVersionClient,
135+
actor_version_collection_client=ActorVersionCollectionClient,
131136
build_client=BuildClient,
132137
build_collection_client=BuildCollectionClient,
133-
run_client=RunClient,
134-
run_collection_client=RunCollectionClient,
135138
dataset_client=DatasetClient,
139+
dataset_collection_client=DatasetCollectionClient,
136140
key_value_store_client=KeyValueStoreClient,
141+
key_value_store_collection_client=KeyValueStoreCollectionClient,
142+
log_client=LogClient,
143+
status_message_watcher=StatusMessageWatcherSync,
144+
streamed_log=StreamedLogSync,
137145
request_queue_client=RequestQueueClient,
146+
request_queue_collection_client=RequestQueueCollectionClient,
147+
run_client=RunClient,
148+
run_collection_client=RunCollectionClient,
149+
schedule_client=ScheduleClient,
150+
schedule_collection_client=ScheduleCollectionClient,
151+
store_collection_client=StoreCollectionClient,
152+
task_client=TaskClient,
153+
task_collection_client=TaskCollectionClient,
154+
user_client=UserClient,
138155
webhook_client=WebhookClient,
139156
webhook_collection_client=WebhookCollectionClient,
157+
webhook_dispatch_client=WebhookDispatchClient,
140158
webhook_dispatch_collection_client=WebhookDispatchCollectionClient,
141-
log_client=LogClient,
142159
)
143160
"""Registry of resource client classes used for dependency injection."""
144161

@@ -352,21 +369,34 @@ def __init__(
352369

353370
self._client_registry = ClientRegistryAsync(
354371
actor_client=ActorClientAsync,
355-
actor_version_client=ActorVersionClientAsync,
356-
actor_version_collection_client=ActorVersionCollectionClientAsync,
372+
actor_collection_client=ActorCollectionClientAsync,
357373
actor_env_var_client=ActorEnvVarClientAsync,
358374
actor_env_var_collection_client=ActorEnvVarCollectionClientAsync,
375+
actor_version_client=ActorVersionClientAsync,
376+
actor_version_collection_client=ActorVersionCollectionClientAsync,
359377
build_client=BuildClientAsync,
360378
build_collection_client=BuildCollectionClientAsync,
361-
run_client=RunClientAsync,
362-
run_collection_client=RunCollectionClientAsync,
363379
dataset_client=DatasetClientAsync,
380+
dataset_collection_client=DatasetCollectionClientAsync,
364381
key_value_store_client=KeyValueStoreClientAsync,
382+
key_value_store_collection_client=KeyValueStoreCollectionClientAsync,
383+
log_client=LogClientAsync,
384+
status_message_watcher=StatusMessageWatcherAsync,
385+
streamed_log=StreamedLogAsync,
365386
request_queue_client=RequestQueueClientAsync,
387+
request_queue_collection_client=RequestQueueCollectionClientAsync,
388+
run_client=RunClientAsync,
389+
run_collection_client=RunCollectionClientAsync,
390+
schedule_client=ScheduleClientAsync,
391+
schedule_collection_client=ScheduleCollectionClientAsync,
392+
store_collection_client=StoreCollectionClientAsync,
393+
task_client=TaskClientAsync,
394+
task_collection_client=TaskCollectionClientAsync,
395+
user_client=UserClientAsync,
366396
webhook_client=WebhookClientAsync,
367397
webhook_collection_client=WebhookCollectionClientAsync,
398+
webhook_dispatch_client=WebhookDispatchClientAsync,
368399
webhook_dispatch_collection_client=WebhookDispatchCollectionClientAsync,
369-
log_client=LogClientAsync,
370400
)
371401
"""Registry of resource client classes used for dependency injection."""
372402

src/apify_client/_client_registry.py

Lines changed: 66 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from apify_client._resource_clients import (
88
ActorClient,
99
ActorClientAsync,
10+
ActorCollectionClient,
11+
ActorCollectionClientAsync,
1012
ActorEnvVarClient,
1113
ActorEnvVarClientAsync,
1214
ActorEnvVarCollectionClient,
@@ -21,20 +23,44 @@
2123
BuildCollectionClientAsync,
2224
DatasetClient,
2325
DatasetClientAsync,
26+
DatasetCollectionClient,
27+
DatasetCollectionClientAsync,
2428
KeyValueStoreClient,
2529
KeyValueStoreClientAsync,
30+
KeyValueStoreCollectionClient,
31+
KeyValueStoreCollectionClientAsync,
2632
LogClient,
2733
LogClientAsync,
2834
RequestQueueClient,
2935
RequestQueueClientAsync,
36+
RequestQueueCollectionClient,
37+
RequestQueueCollectionClientAsync,
3038
RunClient,
3139
RunClientAsync,
3240
RunCollectionClient,
3341
RunCollectionClientAsync,
42+
ScheduleClient,
43+
ScheduleClientAsync,
44+
ScheduleCollectionClient,
45+
ScheduleCollectionClientAsync,
46+
StatusMessageWatcherAsync,
47+
StatusMessageWatcherSync,
48+
StoreCollectionClient,
49+
StoreCollectionClientAsync,
50+
StreamedLogAsync,
51+
StreamedLogSync,
52+
TaskClient,
53+
TaskClientAsync,
54+
TaskCollectionClient,
55+
TaskCollectionClientAsync,
56+
UserClient,
57+
UserClientAsync,
3458
WebhookClient,
3559
WebhookClientAsync,
3660
WebhookCollectionClient,
3761
WebhookCollectionClientAsync,
62+
WebhookDispatchClient,
63+
WebhookDispatchClientAsync,
3864
WebhookDispatchCollectionClient,
3965
WebhookDispatchCollectionClientAsync,
4066
)
@@ -44,72 +70,75 @@
4470
class ClientRegistry:
4571
"""Bundle of all sync client classes for dependency injection.
4672
47-
This config object is passed through the client hierarchy to avoid
48-
parameter explosion when clients need to create other clients.
49-
Each resource client receives this config and can instantiate other
50-
clients as needed without knowing about transitive dependencies.
73+
This config object is passed to the resource clients to avoid circular dependencies. Each resource client
74+
receives this config and can instantiate other clients as needed.
5175
"""
5276

53-
# Actor-related
5477
actor_client: type[ActorClient]
55-
actor_version_client: type[ActorVersionClient]
56-
actor_version_collection_client: type[ActorVersionCollectionClient]
78+
actor_collection_client: type[ActorCollectionClient]
5779
actor_env_var_client: type[ActorEnvVarClient]
5880
actor_env_var_collection_client: type[ActorEnvVarCollectionClient]
59-
60-
# Build-related
81+
actor_version_client: type[ActorVersionClient]
82+
actor_version_collection_client: type[ActorVersionCollectionClient]
6183
build_client: type[BuildClient]
6284
build_collection_client: type[BuildCollectionClient]
63-
64-
# Run-related
65-
run_client: type[RunClient]
66-
run_collection_client: type[RunCollectionClient]
67-
68-
# Storage-related
6985
dataset_client: type[DatasetClient]
86+
dataset_collection_client: type[DatasetCollectionClient]
7087
key_value_store_client: type[KeyValueStoreClient]
88+
key_value_store_collection_client: type[KeyValueStoreCollectionClient]
89+
log_client: type[LogClient]
90+
status_message_watcher: type[StatusMessageWatcherSync]
91+
streamed_log: type[StreamedLogSync]
7192
request_queue_client: type[RequestQueueClient]
72-
73-
# Webhook-related
93+
request_queue_collection_client: type[RequestQueueCollectionClient]
94+
run_client: type[RunClient]
95+
run_collection_client: type[RunCollectionClient]
96+
schedule_client: type[ScheduleClient]
97+
schedule_collection_client: type[ScheduleCollectionClient]
98+
store_collection_client: type[StoreCollectionClient]
99+
task_client: type[TaskClient]
100+
task_collection_client: type[TaskCollectionClient]
101+
user_client: type[UserClient]
74102
webhook_client: type[WebhookClient]
75103
webhook_collection_client: type[WebhookCollectionClient]
104+
webhook_dispatch_client: type[WebhookDispatchClient]
76105
webhook_dispatch_collection_client: type[WebhookDispatchCollectionClient]
77106

78-
# Utilities
79-
log_client: type[LogClient]
80-
81107

82108
@dataclass
83109
class ClientRegistryAsync:
84110
"""Bundle of all async client classes for dependency injection.
85111
86-
Async version of ClientRegistry for use with ApifyClientAsync.
112+
This config object is passed to the resource clients to avoid circular dependencies. Each resource client
113+
receives this config and can instantiate other clients as needed.
87114
"""
88115

89-
# Actor-related
90116
actor_client: type[ActorClientAsync]
91-
actor_version_client: type[ActorVersionClientAsync]
92-
actor_version_collection_client: type[ActorVersionCollectionClientAsync]
117+
actor_collection_client: type[ActorCollectionClientAsync]
93118
actor_env_var_client: type[ActorEnvVarClientAsync]
94119
actor_env_var_collection_client: type[ActorEnvVarCollectionClientAsync]
95-
96-
# Build-related
120+
actor_version_client: type[ActorVersionClientAsync]
121+
actor_version_collection_client: type[ActorVersionCollectionClientAsync]
97122
build_client: type[BuildClientAsync]
98123
build_collection_client: type[BuildCollectionClientAsync]
99-
100-
# Run-related
101-
run_client: type[RunClientAsync]
102-
run_collection_client: type[RunCollectionClientAsync]
103-
104-
# Storage-related
105124
dataset_client: type[DatasetClientAsync]
125+
dataset_collection_client: type[DatasetCollectionClientAsync]
106126
key_value_store_client: type[KeyValueStoreClientAsync]
127+
key_value_store_collection_client: type[KeyValueStoreCollectionClientAsync]
128+
log_client: type[LogClientAsync]
129+
status_message_watcher: type[StatusMessageWatcherAsync]
130+
streamed_log: type[StreamedLogAsync]
107131
request_queue_client: type[RequestQueueClientAsync]
108-
109-
# Webhook-related
132+
request_queue_collection_client: type[RequestQueueCollectionClientAsync]
133+
run_client: type[RunClientAsync]
134+
run_collection_client: type[RunCollectionClientAsync]
135+
schedule_client: type[ScheduleClientAsync]
136+
schedule_collection_client: type[ScheduleCollectionClientAsync]
137+
store_collection_client: type[StoreCollectionClientAsync]
138+
task_client: type[TaskClientAsync]
139+
task_collection_client: type[TaskCollectionClientAsync]
140+
user_client: type[UserClientAsync]
110141
webhook_client: type[WebhookClientAsync]
111142
webhook_collection_client: type[WebhookCollectionClientAsync]
143+
webhook_dispatch_client: type[WebhookDispatchClientAsync]
112144
webhook_dispatch_collection_client: type[WebhookDispatchCollectionClientAsync]
113-
114-
# Utilities
115-
log_client: type[LogClientAsync]

src/apify_client/_resource_clients/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
from .dataset_collection import DatasetCollectionClient, DatasetCollectionClientAsync
1111
from .key_value_store import KeyValueStoreClient, KeyValueStoreClientAsync
1212
from .key_value_store_collection import KeyValueStoreCollectionClient, KeyValueStoreCollectionClientAsync
13-
from .log import LogClient, LogClientAsync
13+
from .log import (
14+
LogClient,
15+
LogClientAsync,
16+
StatusMessageWatcherAsync,
17+
StatusMessageWatcherSync,
18+
StreamedLogAsync,
19+
StreamedLogSync,
20+
)
1421
from .request_queue import RequestQueueClient, RequestQueueClientAsync
1522
from .request_queue_collection import RequestQueueCollectionClient, RequestQueueCollectionClientAsync
1623
from .run import RunClient, RunClientAsync
@@ -65,8 +72,12 @@
6572
'ScheduleClientAsync',
6673
'ScheduleCollectionClient',
6774
'ScheduleCollectionClientAsync',
75+
'StatusMessageWatcherAsync',
76+
'StatusMessageWatcherSync',
6877
'StoreCollectionClient',
6978
'StoreCollectionClientAsync',
79+
'StreamedLogAsync',
80+
'StreamedLogSync',
7081
'TaskClient',
7182
'TaskClientAsync',
7283
'TaskCollectionClient',

0 commit comments

Comments
 (0)