Delete Job#

Delete a completed or failed NeMo Safe Synthesizer job to clean up resources and remove job history.

Prerequisites#

Before you can delete a NeMo Safe Synthesizer job, make sure that you have:

  • Obtained the base URL of your NeMo Safe Synthesizer service

  • Set the SAFE_SYN_BASE_URL environment variable to your NeMo Safe Synthesizer service endpoint

  • A completed or failed job that you want to remove

export SAFE_SYN_BASE_URL="https://your-safe-synthesizer-service-url"

To Delete a NeMo Safe Synthesizer Job#

Choose one of the following options to delete a NeMo Safe Synthesizer job.

import os
from nemo_microservices import NeMoMicroservices

# Initialize the client
client = NeMoMicroservices(
    base_url=os.environ['SAFE_SYN_BASE_URL']
)

# Delete a specific job
job_id = "job-abc123def456"

try:
    client.beta.safe_synthesizer.jobs.delete(job_id)
    print(f"Successfully deleted job: {job_id}")
except Exception as e:
    print(f"Failed to delete job {job_id}: {e}")
JOB_ID="job-abc123def456"

# Delete the job
curl -X DELETE \
  "${SAFE_SYN_BASE_URL}/v1beta1/safe-synthesizer/jobs/${JOB_ID}" \
  -H 'Accept: application/json'

echo "Job deletion request sent"

Important Considerations#

Warning

Permanent Action: Deleting a job is permanent and cannot be undone. This will remove:

  • Job configuration and metadata

  • Job execution logs

  • Any associated results or artifacts

Make sure you have downloaded any results you need before deleting the job.

When to Delete Jobs#

Consider deleting jobs in these scenarios:

  • Completed jobs: After downloading results and no longer needed for reference

  • Failed jobs: After troubleshooting and determining they won’t be retried

  • Test jobs: Development or testing jobs that are no longer relevant

  • Resource cleanup: To free up storage and reduce clutter in job listings

Best Practices#

  1. Download results first: Always retrieve any important results before deletion

  2. Check job status: Verify the job is completed or failed before deleting

  3. Keep important jobs: Consider keeping successful production jobs for audit trails

  4. Batch cleanup: Delete multiple obsolete jobs together for efficiency

Error Handling#

Common errors when deleting jobs:

  • Job not found: The job ID doesn’t exist or has already been deleted

  • Active job: Cannot delete jobs that are currently running (cancel first)

  • Permission denied: Insufficient permissions to delete the job

# Example with error handling
def safe_delete_job(client, job_id):
    try:
        # Check job status first
        job = client.beta.safe_synthesizer.jobs.retrieve(job_id)
        
        if job.status in ("active", "created"):
            print(f"Cannot delete active job {job_id}. Cancel it first.")
            return False
            
        # Proceed with deletion
        client.beta.safe_synthesizer.jobs.delete(job_id)
        print(f"Successfully deleted job: {job_id}")
        return True
        
    except Exception as e:
        print(f"Error deleting job {job_id}: {e}")
        return False