From 2539f9bc6b98e718260d1998969f57609c4e4fc8 Mon Sep 17 00:00:00 2001 From: glrs <5999366+glrs@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:31:19 +0100 Subject: [PATCH] Rename 'process' method to 'launch' across core and realms --- lib/base/abstract_project.py | 9 ++------- lib/realms/smartseq3/smartseq3.py | 15 ++------------- lib/realms/tenx/tenx_project.py | 8 ++------ ygg-mule.py | 2 +- ygg_trunk.py | 5 ++--- 5 files changed, 9 insertions(+), 30 deletions(-) diff --git a/lib/base/abstract_project.py b/lib/base/abstract_project.py index 3fc60be..852cf7b 100644 --- a/lib/base/abstract_project.py +++ b/lib/base/abstract_project.py @@ -33,19 +33,14 @@ def __init__(self, doc: Any, yggdrasil_db_manager: Any) -> None: self.yggdrasil_db_manager: Any = yggdrasil_db_manager @abstractmethod - def pre_process(self) -> None: - """Handle preliminary processing specific to the realm's requirements.""" - pass - - @abstractmethod - async def process(self) -> None: + async def launch(self) -> None: """Define the main processing logic for the project. This method should be implemented by each project class to define how the processing of the document unfolds. Note: - Since processing might involve asynchronous operations (e.g., submitting and monitoring jobs), + Since its course might involve asynchronous operations (e.g., submitting and monitoring jobs), this method is defined as asynchronous. """ pass diff --git a/lib/realms/smartseq3/smartseq3.py b/lib/realms/smartseq3/smartseq3.py index 3aef0ce..ef96f79 100644 --- a/lib/realms/smartseq3/smartseq3.py +++ b/lib/realms/smartseq3/smartseq3.py @@ -151,10 +151,8 @@ def ensure_project_directory(self): logging.error(f"Failed to create project directory: {e}") return None - async def process(self): - """ - Process the SmartSeq3 project by handling its samples. - """ + async def launch(self): + """Launch the SmartSeq3 Realm to handle its samples.""" self.status = "processing" logging.info( f"Processing SmartSeq3 project {self.project_info['project_name']}" @@ -212,15 +210,6 @@ def _generate_ngi_report(self): else: logging.error("Failed to generate the NGI report.") - def pre_process(self, doc): - """ - Pre-process method placeholder. - - Args: - doc (dict): Document to pre-process. - """ - pass - def create_slurm_job(self, sample): """ Placeholder for creating a Slurm job on the project level. diff --git a/lib/realms/tenx/tenx_project.py b/lib/realms/tenx/tenx_project.py index 66985c5..e4c0ed5 100644 --- a/lib/realms/tenx/tenx_project.py +++ b/lib/realms/tenx/tenx_project.py @@ -397,12 +397,8 @@ def extract_samples(self) -> List[TenXRunSample]: run_samples = self.create_run_samples(grouped_lab_samples) return run_samples - def pre_process(self) -> None: - """Perform any pre-processing steps required before processing the project.""" - pass - - async def process(self): - """Process the TenX project by handling its samples.""" + async def launch(self): + """Launch the TenX Realm to handle its samples.""" logging.info(f"Processing TenX project {self.project_info['project_name']}") self.status = "processing" diff --git a/ygg-mule.py b/ygg-mule.py index 3f41105..7b7179b 100644 --- a/ygg-mule.py +++ b/ygg-mule.py @@ -71,7 +71,7 @@ def process_document(doc_id): if RealmClass: realm = RealmClass(document, ydm) if realm.proceed: - asyncio.run(realm.process()) + asyncio.run(realm.launch()) logging.info("Processing complete.") else: logging.info( diff --git a/ygg_trunk.py b/ygg_trunk.py index 1f1961b..f5b0710 100644 --- a/ygg_trunk.py +++ b/ygg_trunk.py @@ -56,13 +56,12 @@ async def process_couchdb_changes(): RealmClass = Ygg.load_realm_class(module_loc) if RealmClass: - # Call the module's process function + # Call the module's launch function realm = RealmClass(data, ydm) if realm.proceed: - task = asyncio.create_task(realm.process()) + task = asyncio.create_task(realm.launch()) tasks.append(task) # print(f"Tasks ({realm.project_info['project_id']}): {tasks}") - # module.process(data) else: logging.info( f"Skipping task creation due to missing required information. {data.get('project_id')}"