Skip to content

Commit 82e65fc

Browse files
committed
Move default storage IDs to Configuration
1 parent 5869f8e commit 82e65fc

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

src/apify/_actor.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -682,23 +682,7 @@ def get_env(self) -> dict:
682682
config[alias] = getattr(self._configuration, field_name)
683683

684684
env_vars = {env_var.value.lower(): env_var.name.lower() for env_var in [*ActorEnvVars, *ApifyEnvVars]}
685-
result = {option_name: config[env_var] for env_var, option_name in env_vars.items() if env_var in config}
686-
687-
# These environment variables are not part of the Configuration model,
688-
# so we need to add them manually to the result dictionary.
689-
result[ActorEnvVars.DEFAULT_DATASET_ID.name.lower()] = os.environ.get(
690-
ActorEnvVars.DEFAULT_DATASET_ID.value
691-
) or os.environ.get(ApifyEnvVars.DEFAULT_DATASET_ID.value)
692-
693-
result[ActorEnvVars.DEFAULT_KEY_VALUE_STORE_ID.name.lower()] = os.environ.get(
694-
ActorEnvVars.DEFAULT_KEY_VALUE_STORE_ID.value
695-
) or os.environ.get(ApifyEnvVars.DEFAULT_KEY_VALUE_STORE_ID.value)
696-
697-
result[ActorEnvVars.DEFAULT_REQUEST_QUEUE_ID.name.lower()] = os.environ.get(
698-
ActorEnvVars.DEFAULT_REQUEST_QUEUE_ID.value
699-
) or os.environ.get(ApifyEnvVars.DEFAULT_REQUEST_QUEUE_ID.value)
700-
701-
return result
685+
return {option_name: config[env_var] for env_var, option_name in env_vars.items() if env_var in config}
702686

703687
async def start(
704688
self,

src/apify/_configuration.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,39 @@ class Configuration(CrawleeConfiguration):
140140
),
141141
] = None
142142

143+
default_dataset_id: Annotated[
144+
str,
145+
Field(
146+
validation_alias=AliasChoices(
147+
'actor_default_dataset_id',
148+
'apify_default_dataset_id',
149+
),
150+
description='Default dataset ID used by the Apify storage client when no ID or name is provided.',
151+
),
152+
] = 'default'
153+
154+
default_key_value_store_id: Annotated[
155+
str,
156+
Field(
157+
validation_alias=AliasChoices(
158+
'actor_default_key_value_store_id',
159+
'apify_default_key_value_store_id',
160+
),
161+
description='Default key-value store ID for the Apify storage client when no ID or name is provided.',
162+
),
163+
] = 'default'
164+
165+
default_request_queue_id: Annotated[
166+
str,
167+
Field(
168+
validation_alias=AliasChoices(
169+
'actor_default_request_queue_id',
170+
'apify_default_request_queue_id',
171+
),
172+
description='Default request queue ID for the Apify storage client when no ID or name is provided.',
173+
),
174+
] = 'default'
175+
143176
disable_outdated_warning: Annotated[
144177
bool,
145178
Field(

0 commit comments

Comments
 (0)