@@ -215,19 +215,16 @@ def get(self, *, synapse_client: Optional[Synapse] = None) -> "CurationTask":
215215
216216 def delete (
217217 self ,
218- delete_file_view : bool = False ,
219- delete_record_set : bool = False ,
218+ delete_source : bool = False ,
220219 * ,
221220 synapse_client : Optional [Synapse ] = None ,
222221 ) -> None :
223222 """
224223 Deletes a CurationTask from Synapse.
225224
226225 Arguments:
227- delete_file_view: If True, the associated EntityView will also be deleted
228- if the task is a FileBasedMetadataTask. Defaults to False.
229- delete_record_set: If True, the associated RecordSet will also be deleted
230- if the task is a RecordBasedMetadataTask. Defaults to False.
226+ delete_source: If True, the associated source data (EntityView or RecordSet) will also be deleted
227+ if the task is a FileBasedMetadataTask or RecordBasedMetadataTask respectively. Defaults to False.
231228 synapse_client: If not passed in and caching was not disabled by
232229 `Synapse.allow_client_caching(False)` this will use the last created
233230 instance from the Synapse class constructor.
@@ -249,7 +246,7 @@ def delete(
249246 task.delete()
250247 ```
251248
252- Example: Delete a curation task and its associated file view
249+ Example: Delete a curation task and its associated data source
253250
254251
255252 ```python
@@ -260,21 +257,7 @@ def delete(
260257 syn.login()
261258
262259 task = CurationTask(task_id=123)
263- task.delete(delete_file_view=True)
264- ```
265-
266- Example: Delete a curation task and its associated record set
267-
268-
269- ```python
270- from synapseclient import Synapse
271- from synapseclient.models import CurationTask
272-
273- syn = Synapse()
274- syn.login()
275-
276- task = CurationTask(task_id=123)
277- task.delete(delete_record_set=True)
260+ task.delete(delete_source=True)
278261 ```
279262 """
280263 return None
@@ -642,29 +625,22 @@ async def main():
642625
643626 async def delete_async (
644627 self ,
645- delete_file_view : bool = False ,
646- delete_record_set : bool = False ,
628+ delete_source : bool = False ,
647629 * ,
648630 synapse_client : Optional [Synapse ] = None ,
649631 ) -> None :
650632 """
651633 Deletes a CurationTask from Synapse.
652634
653635 Arguments:
654- delete_file_view: If True, the associated EntityView will also be deleted
655- if the task is a FileBasedMetadataTask. Defaults to False.
656- delete_record_set: If True, the associated RecordSet will also be deleted
657- if the task is a RecordBasedMetadataTask. Defaults to False.
636+ delete_source: If True, the associated source data (EntityView or RecordSet) will also be deleted
637+ if the task is a FileBasedMetadataTask or RecordBasedMetadataTask respectively. Defaults to False.
658638 synapse_client: If not passed in and caching was not disabled by
659639 `Synapse.allow_client_caching(False)` this will use the last created
660640 instance from the Synapse class constructor.
661641
662642 Raises:
663643 ValueError: If the CurationTask object does not have a task_id.
664- ValueError: If delete_file_view=True but the task is not a FileBasedMetadataTask or does not have a
665- file_view_id.
666- ValueError: If delete_record_set=True but the task is not a RecordBasedMetadataTask or does not have a
667- record_set_id.
668644
669645
670646 Example: Delete a curation task asynchronously
@@ -686,26 +662,7 @@ async def main():
686662 asyncio.run(main())
687663 ```
688664
689- Example: Delete a curation task and its associated file view asynchronously
690-
691-
692- ```python
693- import asyncio
694- from synapseclient import Synapse
695- from synapseclient.models import CurationTask
696-
697- syn = Synapse()
698- syn.login()
699-
700- async def main():
701- task = CurationTask(task_id=123)
702- await task.delete_async(delete_file_view=True)
703- print("Task and file view deleted successfully")
704-
705- asyncio.run(main())
706- ```
707-
708- Example: Delete a curation task and its associated record set asynchronously
665+ Example: Delete a curation task and its associated data source asynchronously
709666
710667
711668 ```python
@@ -718,7 +675,7 @@ async def main():
718675
719676 async def main():
720677 task = CurationTask(task_id=123)
721- await task.delete_async(delete_record_set =True)
678+ await task.delete_async(delete_source =True)
722679 print("Task and record set deleted successfully")
723680
724681 asyncio.run(main())
@@ -733,62 +690,32 @@ async def main():
733690 }
734691 )
735692
736- if delete_file_view or delete_record_set :
693+ if delete_source :
737694 if not self .task_properties :
738695 await self .get_async (synapse_client = synapse_client )
739-
740- if delete_file_view :
741- if (
742- isinstance (self .task_properties , FileBasedMetadataTaskProperties )
743- and self .task_properties .file_view_id
744- ):
745- from synapseclient .models .entityview import EntityView
696+ if isinstance (self .task_properties , FileBasedMetadataTaskProperties ):
697+ if not self .task_properties .file_view_id :
698+ raise ValueError (
699+ "file_view_id is required to delete the associated file view"
700+ )
701+ from synapseclient .models import EntityView
746702
747703 await EntityView (id = self .task_properties .file_view_id ).delete_async (
748704 synapse_client = synapse_client
749705 )
750-
751- elif not isinstance (self .task_properties , FileBasedMetadataTaskProperties ):
752- raise ValueError (
753- (
754- "The `delete_file_view` parameter was set to True, "
755- "but the task is not configured as a FileBasedMetadataTask."
706+ elif isinstance (self .task_properties , RecordBasedMetadataTaskProperties ):
707+ if not self .task_properties .record_set_id :
708+ raise ValueError (
709+ "record_set_id is required to delete the associated record set"
756710 )
757- )
758- else :
759- raise ValueError (
760- (
761- "The `delete_file_view` parameter was set to True, "
762- "but the task does not have an associated file view ID."
763- )
764- )
765-
766- if delete_record_set :
767- if (
768- isinstance (self .task_properties , RecordBasedMetadataTaskProperties )
769- and self .task_properties .record_set_id
770- ):
771- from synapseclient .models .recordset import RecordSet
711+ from synapseclient .models import RecordSet
772712
773713 await RecordSet (id = self .task_properties .record_set_id ).delete_async (
774714 synapse_client = synapse_client
775715 )
776-
777- elif not isinstance (
778- self .task_properties , RecordBasedMetadataTaskProperties
779- ):
780- raise ValueError (
781- (
782- "The `delete_record_set` parameter was set to True, "
783- "but the task is not configured as a RecordBasedMetadataTask."
784- )
785- )
786716 else :
787717 raise ValueError (
788- (
789- "The `delete_record_set` parameter was set to True, "
790- "but the task does not have an associated record set ID."
791- )
718+ "Failed to retrieve task properties for deletion. Cannot delete source."
792719 )
793720
794721 await delete_curation_task (task_id = self .task_id , synapse_client = synapse_client )
0 commit comments