@@ -478,56 +478,68 @@ def _get_storage_client(self, force_cloud: bool) -> Optional[ApifyClientAsync]:
478
478
return self ._apify_client if force_cloud else None
479
479
480
480
@classmethod
481
- async def open_dataset (cls , dataset_id_or_name : Optional [str ] = None , * , force_cloud : bool = False ) -> Dataset :
481
+ async def open_dataset (cls , * , id : Optional [str ] = None , name : Optional [ str ] = None , force_cloud : bool = False ) -> Dataset :
482
482
"""Open a dataset.
483
483
484
484
Datasets are used to store structured data where each object stored has the same attributes,
485
485
such as online store products or real estate offers.
486
486
The actual data is stored either on the local filesystem or in the Apify cloud.
487
487
488
488
Args:
489
- dataset_id_or_name (str, optional): ID or name of the dataset to be opened.
490
- If not provided, the method returns the default dataset associated with the actor run.
489
+ id (str, optional): ID of the dataset to be opened.
490
+ If neither `id` nor `name` are provided, the method returns the default dataset associated with the actor run.
491
+ name (str, optional): Name of the dataset to be opened.
492
+ If neither `id` nor `name` are provided, the method returns the default dataset associated with the actor run.
491
493
force_cloud (bool, optional): If set to `True` then the Apify cloud storage is always used.
492
494
This way it is possible to combine local and cloud storage.
493
495
494
496
Returns:
495
497
Dataset: An instance of the `Dataset` class for the given ID or name.
496
498
497
499
"""
498
- return await cls ._get_default_instance ().open_dataset (dataset_id_or_name = dataset_id_or_name , force_cloud = force_cloud )
500
+ return await cls ._get_default_instance ().open_dataset (id = id , name = name , force_cloud = force_cloud )
499
501
500
- async def _open_dataset_internal (self , dataset_id_or_name : Optional [str ] = None , * , force_cloud : bool = False ) -> Dataset :
502
+ async def _open_dataset_internal (self , * , id : Optional [str ] = None , name : Optional [ str ] = None , force_cloud : bool = False ) -> Dataset :
501
503
self ._raise_if_not_initialized ()
502
504
505
+ dataset_id_or_name = id or name
503
506
return await StorageManager .open_storage (Dataset , dataset_id_or_name , self ._get_storage_client (force_cloud ), self ._config )
504
507
505
508
@classmethod
506
- async def open_key_value_store (cls , key_value_store_id_or_name : Optional [str ] = None , * , force_cloud : bool = False ) -> KeyValueStore :
509
+ async def open_key_value_store (cls , * , id : Optional [str ] = None , name : Optional [ str ] = None , force_cloud : bool = False ) -> KeyValueStore :
507
510
"""Open a key-value store.
508
511
509
512
Key-value stores are used to store records or files, along with their MIME content type.
510
513
The records are stored and retrieved using a unique key.
511
514
The actual data is stored either on a local filesystem or in the Apify cloud.
512
515
513
516
Args:
514
- key_value_store_id_or_name (str, optional): ID or name of the key-value store to be opened.
515
- If not provided, the method returns the default key-value store associated with the actor run.
517
+ id (str, optional): ID of the key-value store to be opened.
518
+ If neither `id` nor `name` are provided, the method returns the default key-value store associated with the actor run.
519
+ name (str, optional): Name of the key-value store to be opened.
520
+ If neither `id` nor `name` are provided, the method returns the default key-value store associated with the actor run.
516
521
force_cloud (bool, optional): If set to `True` then the Apify cloud storage is always used.
517
522
This way it is possible to combine local and cloud storage.
518
523
519
524
Returns:
520
525
KeyValueStore: An instance of the `KeyValueStore` class for the given ID or name.
521
526
"""
522
- return await cls ._get_default_instance ().open_key_value_store (key_value_store_id_or_name = key_value_store_id_or_name , force_cloud = force_cloud )
527
+ return await cls ._get_default_instance ().open_key_value_store (id = id , name = name , force_cloud = force_cloud )
523
528
524
- async def _open_key_value_store_internal (self , key_value_store_id_or_name : Optional [str ] = None , * , force_cloud : bool = False ) -> KeyValueStore :
529
+ async def _open_key_value_store_internal (
530
+ self ,
531
+ * ,
532
+ id : Optional [str ] = None ,
533
+ name : Optional [str ] = None ,
534
+ force_cloud : bool = False ,
535
+ ) -> KeyValueStore :
525
536
self ._raise_if_not_initialized ()
526
537
538
+ key_value_store_id_or_name = id or name
527
539
return await StorageManager .open_storage (KeyValueStore , key_value_store_id_or_name , self ._get_storage_client (force_cloud ), self ._config )
528
540
529
541
@classmethod
530
- async def open_request_queue (cls , request_queue_id_or_name : Optional [str ] = None , * , force_cloud : bool = False ) -> RequestQueue :
542
+ async def open_request_queue (cls , * , id : Optional [str ] = None , name : Optional [ str ] = None , force_cloud : bool = False ) -> RequestQueue :
531
543
"""Open a request queue.
532
544
533
545
Request queue represents a queue of URLs to crawl, which is stored either on local filesystem or in the Apify cloud.
@@ -536,24 +548,28 @@ async def open_request_queue(cls, request_queue_id_or_name: Optional[str] = None
536
548
and depth-first crawling orders.
537
549
538
550
Args:
539
- request_queue_id_or_name (str, optional): ID or name of the request queue to be opened.
540
- If not provided, the method returns the default request queue associated with the actor run.
551
+ id (str, optional): ID of the request queue to be opened.
552
+ If neither `id` nor `name` are provided, the method returns the default request queue associated with the actor run.
553
+ name (str, optional): Name of the request queue to be opened.
554
+ If neither `id` nor `name` are provided, the method returns the default request queue associated with the actor run.
541
555
force_cloud (bool, optional): If set to `True` then the Apify cloud storage is always used.
542
556
This way it is possible to combine local and cloud storage.
543
557
544
558
Returns:
545
559
RequestQueue: An instance of the `RequestQueue` class for the given ID or name.
546
560
"""
547
- return await cls ._get_default_instance ().open_request_queue (request_queue_id_or_name = request_queue_id_or_name , force_cloud = force_cloud )
561
+ return await cls ._get_default_instance ().open_request_queue (id = id , name = name , force_cloud = force_cloud )
548
562
549
563
async def _open_request_queue_internal (
550
564
self ,
551
- request_queue_id_or_name : Optional [str ] = None ,
552
565
* ,
566
+ id : Optional [str ] = None ,
567
+ name : Optional [str ] = None ,
553
568
force_cloud : bool = False ,
554
569
) -> RequestQueue :
555
570
self ._raise_if_not_initialized ()
556
571
572
+ request_queue_id_or_name = id or name
557
573
return await StorageManager .open_storage (RequestQueue , request_queue_id_or_name , self ._get_storage_client (force_cloud ), self ._config )
558
574
559
575
@classmethod
0 commit comments