@@ -158,6 +158,16 @@ def _raise_if_not_initialized(self) -> None:
158
158
if not self ._is_initialized :
159
159
raise RuntimeError ('The Actor was not initialized!' )
160
160
161
+ def _raise_if_cloud_requested_but_not_configured (self , * , force_cloud : bool ) -> None :
162
+ if not force_cloud :
163
+ return
164
+
165
+ if not self .is_at_home () and self .config .token is None :
166
+ raise RuntimeError (
167
+ 'In order to use the Apify cloud storage from your computer, '
168
+ 'you need to provide an Apify token using the APIFY_TOKEN environment variable.'
169
+ )
170
+
161
171
async def init (self ) -> None :
162
172
"""Initialize the Actor instance.
163
173
@@ -335,6 +345,7 @@ async def open_dataset(
335
345
An instance of the `Dataset` class for the given ID or name.
336
346
"""
337
347
self ._raise_if_not_initialized ()
348
+ self ._raise_if_cloud_requested_but_not_configured (force_cloud = force_cloud )
338
349
339
350
return await Dataset .open (
340
351
id = id ,
@@ -367,6 +378,7 @@ async def open_key_value_store(
367
378
An instance of the `KeyValueStore` class for the given ID or name.
368
379
"""
369
380
self ._raise_if_not_initialized ()
381
+ self ._raise_if_cloud_requested_but_not_configured (force_cloud = force_cloud )
370
382
371
383
return await KeyValueStore .open (
372
384
id = id ,
@@ -401,6 +413,7 @@ async def open_request_queue(
401
413
An instance of the `RequestQueue` class for the given ID or name.
402
414
"""
403
415
self ._raise_if_not_initialized ()
416
+ self ._raise_if_cloud_requested_but_not_configured (force_cloud = force_cloud )
404
417
405
418
return await RequestQueue .open (
406
419
id = id ,
0 commit comments