Hi All, I have this code below in a directory and...
# ask-community
b
Hi All, I have this code below in a directory and in same directory I use prefect deploy command to create a deployment in prefect server.. But my question is - how can we automate that .. is there any direct prefect deploy command for local code (without using docker images or remote storage options)
Copy code
from prefect import flow, task
from prefect_shell import ShellOperation

@task
def run_script():
    command = "/bin/python3.9 /bk01/bk_automations/bk_log_forwarding/run.py --log_dir /u01/bk_automations/BK_automation_logs/ --config_dir /u01/bk_automations/"
    shell_op = ShellOperation(commands=[command])
    return shell_op.run()

@flow(name="BK Log Forwarding Flow")
def log_forwarding_executor():
    run_script()

if __name__ == "__main__":
    log_forwarding_executor()
@Jake Kaplan @Nate Could you please assist
n
hi @Bharat Khaneja tagging prefect employees like this is against our policy. if you think there's a bug, please open an issue if you're just looking for help on what you're trying, feel free to lay out what you're trying to do in detail and explain what's unexpected and someone will try to help as soon as they can
sounds like you want
.serve
or just
.from_source(source={localfilepath}, entrypoint=...).deploy()

https://youtu.be/KzumEnsLOe0?si=3q354dGJK7tPsEla

b
Sorry for that
and thank you, the above is helpful
one question - I am using Postgress in backend for prod deployment of prefect server setup. My existing scripts stream a lot of logs and I am concerned about DB getting full. How can we apply a limit to keep only last 15 days logs
n
so this is something we'd may eventually add to a stock server installation (background jobs to clean up things) but for now I would recommend writing a couple maintenance flows that use the client to clean up old resources. ill also mention that this is an advantage of cloud, ie we implement resource retention for you
🆗 1
b
I can write some cleanup flows, but I'm not sure which specific tables I should target for deletion to avoid interrupting any critical processes. I want to ensure I'm only deleting log-related data and nothing essential for system operation. Could you point me to the log tables or any guidance on which ones I should focus on to ensure that only logs older than 15 days are deleted? I’m aiming for a solution that won't interfere with Prefect's core operations.
Nate, if you could please suggest when you get time