Skip to content

Commit 8de950b

Browse files
committed
opening storages get default id from config
1 parent 82e65fc commit 8de950b

File tree

3 files changed

+3
-27
lines changed

3 files changed

+3
-27
lines changed

src/apify/storage_clients/_apify/_dataset_client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from __future__ import annotations
22

33
import asyncio
4-
import os
54
from logging import getLogger
65
from typing import TYPE_CHECKING, Any
76

87
from typing_extensions import override
98

109
from apify_client import ApifyClientAsync
11-
from apify_shared.consts import ActorEnvVars, ApifyEnvVars
1210
from crawlee.storage_clients._base import DatasetClient
1311
from crawlee.storage_clients.models import DatasetItemsListPage, DatasetMetadata
1412

@@ -99,13 +97,7 @@ async def open(
9997

10098
# If both id and name are None, try to get the default storage ID from environment variables.
10199
if id is None and name is None:
102-
id = os.environ.get(
103-
ActorEnvVars.DEFAULT_DATASET_ID.value,
104-
None,
105-
) or os.environ.get(
106-
ApifyEnvVars.DEFAULT_DATASET_ID.value,
107-
None,
108-
)
100+
id = getattr(configuration, 'default_dataset_id', None)
109101

110102
if id is None:
111103
raise ValueError(

src/apify/storage_clients/_apify/_key_value_store_client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
from __future__ import annotations
22

33
import asyncio
4-
import os
54
from logging import getLogger
65
from typing import TYPE_CHECKING, Any
76

87
from typing_extensions import override
98
from yarl import URL
109

1110
from apify_client import ApifyClientAsync
12-
from apify_shared.consts import ActorEnvVars, ApifyEnvVars
1311
from crawlee.storage_clients._base import KeyValueStoreClient
1412
from crawlee.storage_clients.models import KeyValueStoreMetadata, KeyValueStoreRecord, KeyValueStoreRecordMetadata
1513

@@ -101,13 +99,7 @@ async def open(
10199

102100
# If both id and name are None, try to get the default storage ID from environment variables.
103101
if id is None and name is None:
104-
id = os.environ.get(
105-
ActorEnvVars.DEFAULT_KEY_VALUE_STORE_ID.value,
106-
None,
107-
) or os.environ.get(
108-
ApifyEnvVars.DEFAULT_KEY_VALUE_STORE_ID.value,
109-
None,
110-
)
102+
id = getattr(configuration, 'default_key_value_store_id', None)
111103

112104
if id is None:
113105
raise ValueError(

src/apify/storage_clients/_apify/_request_queue_client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import asyncio
4-
import os
54
from collections import deque
65
from datetime import datetime, timedelta, timezone
76
from logging import getLogger
@@ -11,7 +10,6 @@
1110
from typing_extensions import override
1211

1312
from apify_client import ApifyClientAsync
14-
from apify_shared.consts import ActorEnvVars, ApifyEnvVars
1513
from crawlee._utils.requests import unique_key_to_request_id
1614
from crawlee.storage_clients._base import RequestQueueClient
1715
from crawlee.storage_clients.models import AddRequestsResponse, ProcessedRequest, RequestQueueMetadata
@@ -131,13 +129,7 @@ async def open(
131129

132130
# If both id and name are None, try to get the default storage ID from environment variables.
133131
if id is None and name is None:
134-
id = os.environ.get(
135-
ActorEnvVars.DEFAULT_REQUEST_QUEUE_ID.value,
136-
None,
137-
) or os.environ.get(
138-
ApifyEnvVars.DEFAULT_REQUEST_QUEUE_ID.value,
139-
None,
140-
)
132+
id = getattr(configuration, 'default_request_queue_id', None)
141133

142134
if id is None:
143135
raise ValueError(

0 commit comments

Comments
 (0)