Skip to content

Commit 19b79f1

Browse files
committed
Add upgrading guide
1 parent b7101a4 commit 19b79f1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/04_upgrading/upgrading_to_v3.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,38 @@ This page summarizes the breaking changes between Apify Python SDK v2.x and v3.0
99

1010
Support for Python 3.9 has been dropped. The Apify Python SDK v3.x now requires Python 3.10 or later. Make sure your environment is running a compatible version before upgrading.
1111

12+
## Actor initialization and ServiceLocator changes
13+
14+
`Actor` initialization and global `service_locator` services setup is more strict and predictable.
15+
- Services in `Actor` can't be changed after calling `Actor.init`, entering the `async with Actor` context manager or after requesting them from the `Actor`
16+
- Services in `Actor` can be different from services in Crawler
17+
18+
**Now (v3.0):**
19+
20+
```python
21+
from crawlee.crawlers import BasicCrawler
22+
from crawlee.storage_clients import MemoryStorageClient, FileSystemStorageClient
23+
from crawlee.configuration import Configuration
24+
from crawlee.events import LocalEventManager
25+
from apify import Actor
26+
27+
async def main():
28+
29+
async with Actor():
30+
# This crawler will use same services as Actor and global service_locator
31+
crawler_1 = BasicCrawler()
32+
33+
# This crawler will use custom services
34+
custom_configuration = Configuration()
35+
custom_event_manager = LocalEventManager.from_config(custom_configuration)
36+
custom_storage_client = MemoryStorageClient()
37+
crawler_2 = BasicCrawler(
38+
configuration=custom_configuration,
39+
event_manager=custom_event_manager,
40+
storage_client=custom_storage_client,
41+
)
42+
```
43+
1244
## Storages
1345

1446
<!-- TODO -->

0 commit comments

Comments
 (0)