Skip to content

Commit

Permalink
add helpful typings
Browse files Browse the repository at this point in the history
  • Loading branch information
LuiggiTenorioK committed Dec 17, 2024
1 parent 8a1b2df commit 88535eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
39 changes: 33 additions & 6 deletions autosubmit/autosubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
from configparser import ConfigParser
from distutils.util import strtobool
from pathlib import Path
from autosubmit.job.job import Job
from autosubmit.platforms.submitter import Submitter
from ruamel.yaml import YAML
from typing import Dict, Set, Tuple, Union
from typing import Dict, Optional, Set, Tuple, Union

from autosubmit.database.db_common import update_experiment_descrip_version
from autosubmit.helpers.parameters import PARAMETERS
Expand Down Expand Up @@ -1840,8 +1842,14 @@ def job_notify(as_conf,expid,job,job_prev_status,job_changes_tracker):
Status.VALUE_TO_KEY[job.status],
as_conf.experiment_data["MAIL"]["TO"])
return job_changes_tracker

@staticmethod
def check_wrappers(as_conf, job_list, platforms_to_test, expid):
def check_wrappers(
as_conf: AutosubmitConfig,
job_list: JobList,
platforms_to_test: Set[Platform],
expid: str,
) -> Tuple[Dict[str, List[Job]], Dict[str, Tuple[Status, Status]]]:
"""
Check wrappers and inner jobs status also order the non-wrapped jobs to be submitted by active platforms
:param as_conf: a AutosubmitConfig object
Expand All @@ -1850,8 +1858,8 @@ def check_wrappers(as_conf, job_list, platforms_to_test, expid):
:param expid: a string with the experiment id
:return: non-wrapped jobs to check and a dictionary with the changes in the jobs status
"""
jobs_to_check = dict()
job_changes_tracker = dict()
jobs_to_check: Dict[str, List[Job]] = dict()
job_changes_tracker: Dict[str, Tuple[Status, Status]] = dict()
for platform in platforms_to_test:
queuing_jobs = job_list.get_in_queue_grouped_id(platform)
Log.debug('Checking jobs for platform={0}'.format(platform.name))
Expand Down Expand Up @@ -1931,6 +1939,7 @@ def check_wrapper_stored_status(as_conf,job_list):
None, jobs[0].platform, as_conf, jobs[0].hold)
job_list.job_package_map[jobs[0].id] = wrapper_job
return job_list

@staticmethod
def get_historical_database(expid, job_list, as_conf):
"""
Expand Down Expand Up @@ -1981,9 +1990,26 @@ def process_historical_data_iteration(job_list,job_changes_tracker, expid):
exp_history.process_job_list_changes_to_experiment_totals(job_list.get_job_list())
Autosubmit.database_backup(expid)
return exp_history

@staticmethod
def prepare_run(expid, notransitive=False, start_time=None, start_after=None,
run_only_members=None, recover = False, check_scripts= False):
def prepare_run(
expid: str,
notransitive: bool = False,
start_time: str = None,
start_after: str = None,
run_only_members: str = None,
recover: bool = False,
check_scripts: bool = False,
) -> Tuple[
JobList,
Submitter,
Optional[ExperimentHistory],
Optional[str],
AutosubmitConfig,
Set[Platform],
JobPackagePersistence,
bool,
]:
"""
Prepare the run of the experiment.
:param expid: a string with the experiment id.
Expand Down Expand Up @@ -2141,6 +2167,7 @@ def prepare_run(expid, notransitive=False, start_time=None, start_after=None,
return job_list, submitter , exp_history, host , as_conf, platforms_to_test, packages_persistence, False
else:
return job_list, submitter , None, None, as_conf , platforms_to_test, packages_persistence, True

@staticmethod
def get_iteration_info(as_conf,job_list):
"""
Expand Down
5 changes: 4 additions & 1 deletion autosubmit/job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ def is_over_wallclock(self, start_time, wallclock):
return True
return False

def update_status(self, as_conf, failed_file=False):
def update_status(self, as_conf: AutosubmitConfig, failed_file: bool = False) -> Status:
"""
Updates job status, checking COMPLETED file if needed
Expand Down Expand Up @@ -1306,6 +1306,9 @@ def update_status(self, as_conf, failed_file=False):
self.retrieve_logfiles(self.platform)
else:
self.platform.add_job_to_log_recover(self)

# TODO Read and store metrics here

return self.status

@staticmethod
Expand Down

0 comments on commit 88535eb

Please sign in to comment.