Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: Better error message when attempting to use force_cloud without an Apify token #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions 13 src/apify/_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ def _raise_if_not_initialized(self) -> None:
if not self._is_initialized:
raise RuntimeError('The Actor was not initialized!')

def _raise_if_cloud_requested_but_not_configured(self, *, force_cloud: bool) -> None:
if not force_cloud:
return

if not self.is_at_home() and self.config.token is None:
raise RuntimeError(
'In order to use the Apify cloud storage from your computer, '
'you need to provide an Apify token using the APIFY_TOKEN environment variable.'
)

async def init(self) -> None:
"""Initialize the Actor instance.

Expand Down Expand Up @@ -335,6 +345,7 @@ async def open_dataset(
An instance of the `Dataset` class for the given ID or name.
"""
self._raise_if_not_initialized()
self._raise_if_cloud_requested_but_not_configured(force_cloud=force_cloud)

return await Dataset.open(
id=id,
Expand Down Expand Up @@ -367,6 +378,7 @@ async def open_key_value_store(
An instance of the `KeyValueStore` class for the given ID or name.
"""
self._raise_if_not_initialized()
self._raise_if_cloud_requested_but_not_configured(force_cloud=force_cloud)

return await KeyValueStore.open(
id=id,
Expand Down Expand Up @@ -401,6 +413,7 @@ async def open_request_queue(
An instance of the `RequestQueue` class for the given ID or name.
"""
self._raise_if_not_initialized()
self._raise_if_cloud_requested_but_not_configured(force_cloud=force_cloud)

return await RequestQueue.open(
id=id,
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.