Clean up import_processing (#928) - #1847
Open
davmlaw wants to merge 1 commit into
Open
Conversation
UploadPipelineFinishedTask ran ahead of pipeline_success_task in the FINISH chain and set the status to SUCCESS, so the success task's "status == PROCESSING" guard swallowed the real close - taking the step timings, the import_*_success event and the file cleanup with it. Delete the task and leave pipeline_success_task as the single closer. - UploadPipeline gets a post_delete receiver, so a deleted pipeline takes its processing dir - and the VCF we generated as its input, for liftover / manual variant entry / classification import - with it. - django_file_utils splits naming a scratch dir (import_processing_dir_path) from creating one (get_import_processing_dir), and adds remove_import_processing_dir. ClinGenAlleleRegistryAPI no longer mints an empty dir per instance just to name a failure dump it will probably never write. - gene_annotation, human_protein_atlas_import and gene coverage remove their COPY CSVs, the last of those now gated on IMPORT_PROCESSING_DELETE_TEMP_FILES_ON_SUCCESS rather than not DEBUG. - Tests get their own IMPORT_PROCESSING_DIR under the temp dir, removed by the test runner, so they stop writing into the real tree. - New management command import_processing_cleanup (--dry-run) sweeps what leaked before this, registered as a ManualOperation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #928
The bug
schedule_pipeline_stage_stepsbuilds the FINISH stage as a chain of the FINISH-dependent steps followed bypipeline_success_task.AbstractVCFImportTaskFactory.get_finish_task_classes()returned[UploadPipelineFinishedTask], which setstatus = SUCCESS- sopipeline_success_task'sstatus == PROCESSINGguard then made it a no-op, andUploadPipeline.success()never ran.That is the only place that records
processing_seconds_*, fires theimport_*_successevent and callsremove_processing_files(). On this dev box, 156 of 178 SUCCESS pipelines haveprocessing_seconds_wall_time IS NULL- all of them factories inheriting that finish list (Liftover, Manual Variant Entry, insert-variants-only, Variant Tags, TSO500). The 22 with timings are the three factories that don't (ClinVar, Patient Records, genotype VCF), which is also the proof thatpipeline_success_taskcloses a pipeline correctly on its own.So yes to the question in the issue comment: the two were duplicates and
UploadPipelineFinishedTaskwas the redundant one. It is deleted;pipeline_success_taskis now the single closer and keeps its guard (FINISH can legitimately be scheduled twice, and the guard is what makes the second run a no-op).Everything else that leaked
post_deletereceiver onUploadPipeline, following theAnnotationRunpattern from Variant Annotation and disk space #1670 - unconditional, since with the row gone nothing can name the directory. Registering a receiver also disables Django's fast-delete path, so it fires onFileUpload/VCFcascades too.FileUpload.pathat it; nothing removed it. NewFileUpload.is_import_processing_scratch+UploadPipeline.remove_generated_input_file(), called fromsuccess()(under the setting) and the receiver (unconditional).retry_upload_pipelinestill only removes the pipeline's own dir, so a retry keeps its input.get_import_processing_dir()created the dir on every call. Split intoimport_processing_dir_path(pure) andget_import_processing_dir(creates), plusremove_import_processing_dir.ClinGenAlleleRegistryAPI.__init__computed a failure-dump path eagerly, minting an emptyclingen_allele_registry_<uuid>dir per instance - now worked out inside the except branch, into one sharedclingen_allele_registry_failures/.gene_annotationandhuman_protein_atlas_importnow remove their COPY CSV; gene coverage cleanup moves offnot settings.DEBUGontoIMPORT_PROCESSING_DELETE_TEMP_FILES_ON_SUCCESS.IMPORT_PROCESSING_DIRpoints at a temp dir underUNIT_TEST, removed byVariantGridTestRunner.teardown_test_environment;fake_annotationbuilds its per-test dir inside it.Sweep for existing deployments
manage.py import_processing_cleanup [--dry-run] [--min-age-days N]walks the top level ofIMPORT_PROCESSING_DIRand removes only entries whose owner is finished with them (row gone, or SUCCESS/FINISHED). A PROCESSING pipeline, an ERROR annotation run, a non-empty ClinGen dump dir, anything modified within--min-age-days, and any unrecognised name are reported and left alone. Registered as aManualOperationinupload/migrations/0042_one_off_import_processing_cleanup.py, gated on the directory being non-empty.Sample dry run on this box:
Notes
UploadSteprows namingUploadPipelineFinishedTaskbelong to finished pipelines and are never re-launched (schedule_pipeline_stage_stepsfiltersstart_date__isnull=True); a retry rebuilds its steps from the factory.view_upload_pipelinealready handles a missing file.upload/tests/test_pipeline_cleanup.py,upload/tests/test_import_processing_cleanup.py.claude/plans/928_import_processing_cleanup_plan.mddeleted; its knowledge is now inclaude/research/upload.mdandupload/CLAUDE.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01F1Rk7aXMC6RFc6oouK6Hck