New RunLLM response generated: >>>*# Question* He...
# runllm-flyte-trial
a
New RunLLM response generated: >>>*# Question* Hello! Can you guide me what is the best way to delete old executions (and the data connected to them). As I know flyte doesn't have a method for that, but still I need to release disk space and I would like to delete data which are not useful anymore. I tried to access s3 uri (e.g. s3://flyte/data/9m/fca9028c0ffe64016afa-n3-0-n3-n1-0-n1-0/3f275b36950b20fc8436681ba76437bd/8a664494c61b5de20e002fe0618ab938) when it's available and delete it by boto3 client but it didn't release any disk space. I don't care about inconsistency right now because they are old executions which I don't want to utilize anymore. Can you suggest me the less hacky / the best way to delete these? # Answer Flyte currently does not provide a built-in feature to delete old executions and their associated data directly. However, there are some approaches you can take to manage and delete old data: 1. Manual Deletion via S3 Lifecycle Policies: You can set up lifecycle policies in S3 to automatically delete objects after a certain period. This approach ensures that data is deleted without manual intervention. According to this discussion, setting lifecycle policies in S3 can help manage the deletion of old data. 2. Database Cleanup: You can manually run delete queries against the Flyte database to remove old execution records. This involves deleting entries from tables such as
executions
,
task_executions
,
node_executions
,
execution-events
, and
node-execution-events
. As per this GitHub issue, you can focus on these tables to clean up old executions. 3. Using
flytectl
: While
flytectl delete execution
can terminate executions, it does not delete the associated data. However, you can use it to identify and manage executions. Refer to the flytectl documentation for more details. 4. Custom Scripts: You can write custom scripts to delete data from both S3 and the Flyte database. For S3, you can use the
boto3
library to delete objects. For the database, you can use SQL queries to delete records. Ensure that your script handles both S3 and database deletions to maintain consistency. Here is an example of how you might use
boto3
to delete S3 objects:
Copy code
import boto3

s3 = boto3.client('s3')

def delete_s3_objects(bucket_name, prefix):
    response = s3.list_objects_v2(Bucket=bucket_name, Prefix=prefix)
    if 'Contents' in response:
        for obj in response['Contents']:
            s3.delete_object(Bucket=bucket_name, Key=obj['Key'])

# Example usage
delete_s3_objects('flyte', 'data/9m/fca9028c0ffe64016afa-n3-0-n3-n1-0-n1-0/3f275b36950b20fc8436681ba76437bd/8a664494c61b5de20e002fe0618ab938')
>>Would you like more detailed steps or additional information on any of these approaches?
Sources: - Flyte GitHub Issue #3596 - Flyte Discussion on S3 Lifecycle Policies - Flytectl Delete Execution Documentation Slack Link https://flyte-org.slack.com/archives/CP2HDHKE1/p1722519343.804059 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.