Closed feliche93 closed 3 years ago
I ran into this issue the other day, Dylan helped me out on the Slack channel.
I defined a local storage and set stored_as_script
to True
.
from prefect.environments.storage import Local
with Flow('Linkedin Automation") as flow:
...
flow.storage = Local(path='path/to/your/flow.py', stored_as_script=True)
flow.run()
@lejimmy thank you so much for helping me out on that :) Works like a charm!
Only thing I noticed is that when I split the tasks up into modules and import functions that I get the same error. So for now I guess I have to all tasks with returned driver objects in one file? Or did you also by any chance face this issue? :)
That’s what I’ve been doing.
Maybe saving your cookies can help you bypass some steps once you’ve already authenticated: https://stackoverflow.com/a/48665557
Answer here and in Slack thread: https://prefect-community.slack.com/archives/CL09KU1K7/p1603318809428700
Archived the thread here for better discoverability: https://github.com/PrefectHQ/prefect/issues/3669
Description
I want to use Prefect for some automated scraping of my own social media stats such as posts, profile views on LinkedIn for example. With a lot of javascript and logging in, headless Selenium is the easiest solution so far.
When I run my code inside the file with
flow.run()
everything works out perfectly.Registering the flow also works, but when I execute it in a local environment, the logs show following issue:
I believe the issue is that I am passing the driver object from one task to the next. However the selenium driver object cannot be pickled as the logs indicate.
Is there any way I can prevent serialising the driver object, and still use the driver (authenticated session) in other tasks? Or what would be a potential work around to make this work?
Expected Behavior
When running the following flow/task in the UI I would expect to not see any issues as when I execute
flow.run()
:Here's my flow:
Environment
Very much appreciate your help!
Thanks, Felix