Hi, I try to build a deployment and upload to minio storage(remote-file-system), the package s3fs al...
e

eli yosef

over 3 years ago
Hi, I try to build a deployment and upload to minio storage(remote-file-system), the package s3fs already install and i put this lines to head of flow.py
from prefect.filesystems import RemoteFileSystem
remote_file_system_block = RemoteFileSystem.load("minio-s3")
I get the error:
root@fd9f23f7b06c:~/flows# prefect deployment build rest_flow_3.py:websites2 -n eli -q check_url_status -sb remote-file-system/minio-s3
Found flow 'test url check flow'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 230, in coroutine_wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 181, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "/usr/local/lib/python3.8/site-packages/anyio/_core/_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
  File "/usr/local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "/usr/local/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
    return await func(*args)
  File "/usr/local/lib/python3.8/site-packages/prefect/cli/deployment.py", line 988, in build
    deployment = await Deployment.build_from_flow(
  File "/usr/local/lib/python3.8/site-packages/prefect/deployments.py", line 755, in build_from_flow
    await deployment.upload_to_storage(ignore_file=ignore_file)
  File "/usr/local/lib/python3.8/site-packages/prefect/deployments.py", line 600, in upload_to_storage
    file_count = await self.storage.put_directory(
  File "/usr/local/lib/python3.8/site-packages/prefect/filesystems.py", line 368, in put_directory
    self.filesystem.put_file(f, fpath, overwrite=True)
  File "/usr/local/lib/python3.8/site-packages/fsspec/asyn.py", line 114, in wrapper
    return sync(self.loop, func, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/fsspec/asyn.py", line 99, in sync
    raise return_result
  File "/usr/local/lib/python3.8/site-packages/fsspec/asyn.py", line 54, in _runner
    result[0] = await coro
  File "/usr/local/lib/python3.8/site-packages/s3fs/core.py", line 1101, in _put_file
    await self._call_s3(
  File "/usr/local/lib/python3.8/site-packages/s3fs/core.py", line 332, in _call_s3
    await self.set_session()
  File "/usr/local/lib/python3.8/site-packages/s3fs/core.py", line 492, in set_session
    self.session = aiobotocore.session.AioSession(**self.kwargs)
TypeError: __init__() got an unexpected keyword argument 'url'
An exception occurred.
my setting is:
{  "url": "<https://172.23.0.5:900>",  "accessKey": "!!!!!!!!!!!!!!!!!",  "secretKey": "===============",  "api": "s3v4",  "path": "auto"}
1
Hi all, I'm overhauling our current Prefect 2.19.1 to Prefect 3.1.0. Because our codebase dynamica...
r

Robert Banick

almost 2 years ago
Hi all, I'm overhauling our current Prefect 2.19.1 to Prefect 3.1.0. Because our codebase dynamically generates a lot of deployments we use Prefect Python and not Prefect YAML to manage everything. Surprisingly the Python code has really stayed mostly the same between versions, which is great. Unsurprisingly some of our side scripts we use to manage the Cloud are now broken. One in particular we use to clear backlogs of Late runs is giving me fits. This code used to work
import asyncio

from prefect.states import State
from prefect.client import get_client

MAX_RUNS_TO_DELETE = 5000
PREFECT_OFFSET_MAX = 200


async def remove_all_flows():
    client = get_client()
    for i in range(0, MAX_RUNS_TO_DELETE, PREFECT_OFFSET_MAX):
        flow_runs = await client.read_flow_runs(offset=i)
        for flow_run in flow_runs:
            if flow_run.state_name == "Late":
                flow_id = flow_run.id
                print("deleting", flow_id)
                await client.set_flow_run_state(flow_run_id=flow_id, state=State(type="CANCELLED"))


asyncio.run(remove_all_flows())
But now returns an error
pydantic.errors.PydanticUserError: `StateCreate` is not fully defined; you should define all referenced types, then call `StateCreate.model_rebuild()`.
No amount of defining State parameters (or passing directly a StateCreate object) fixes the issue. I'm increasingly convinced the old code is now a dead end. Could the Prefect team advise on what the idiomatic way to cancel a Late flow run would be under Prefect 3.1+?
Hey folks, I'm looking into migrating a django + celery app to use Prefect for async task processing...
s

Samuel Schlesinger

over 1 year ago
Hey folks, I'm looking into migrating a django + celery app to use Prefect for async task processing – we run X celery workers, which all listen to a queue broker (redis/rabbitmq/etc), and our API adds jobs to the queue as users trigger events. Pretty standard stuff. I'm trying to recreate a basic version of this in Prefect. I've got a prefect server running; and several workers running in docker instances, each joining a work pool. The workers have the application code baked into the image. In celery-land, I'd just trigger jobs by calling
my_decorated_func.apply_async([args])
, i.e. `say_hello_world.apply_async(["Marvin"])`; and the workers would pick up the jobs, set up app internals (environment config et al), and then run the decorated function automatically. I'm not seeing an obvious way to do this with Prefect. I can call my
say_hello_world
flow directly, and it'll run locally, but I need it to run in the worker pool. Calling
.deploy()
tries to register it with the default worker pool, which is great, but it complains about needing an entrypoint or image. I saw some comments online about using 'local storage' to point to the specific file the flow is in, i.e.
/path/to/file/flow.py:say_hello_world
, but... there's no way that's the "right" way to queue a job, right? I get that the Prefect control plane allows for total independence between the place that's queueing jobs and the place that's executing them, but in my case, they're both the same docker image; just with different entrypoints (starting the API vs starting the prefect workers). What's a clean way to just say "look for this exact same decorated function in the worker", essentially as if it were running locally but in a different container? CC @Marvin