Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commands for flare api for the job components #3247

Merged
merged 9 commits into from
Feb 25, 2025
23 changes: 23 additions & 0 deletions nvflare/fuel/flare_api/api_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,29 @@ def download_job_result(self, job_id: str) -> str:
"""
pass

@abstractmethod
def list_job_components(self, job_id: str) -> List[str]:
"""Get the list of additional job components for the specified job.

Args:
job_id (str): ID of the job

Returns: a list of the additional job components

"""
pass

def download_job_components(self, job_id: str) -> str:
"""Download additional job components (e.g., ERRORLOG_site-1) for a specified job.

Args:
job_id (str): ID of the job

Returns: folder path to the location of the downloaded additional job components

"""
pass

@abstractmethod
def abort_job(self, job_id: str):
"""Abort the specified job
Expand Down
30 changes: 30 additions & 0 deletions nvflare/fuel/flare_api/flare_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,36 @@ def download_job_result(self, job_id: str) -> str:
location = meta.get(MetaKey.LOCATION)
return location

def list_job_components(self, job_id: str) -> List[str]:
"""Get the list of additional job components for the specified job.

Args:
job_id (str): ID of the job

Returns: a list of the additional job components

"""
self._validate_job_id(job_id)
result = self._do_command(AdminCommandNames.LIST_JOB + " " + job_id)
meta = result[ResultKey.META]
job_components_list = meta.get(MetaKey.JOB_COMPONENTS, [])
return job_components_list

def download_job_components(self, job_id: str) -> str:
"""Download additional job components (e.g., ERRORLOG_site-1) for a specified job.

Args:
job_id (str): ID of the job

Returns: folder path to the location of the downloaded additional job components

"""
self._validate_job_id(job_id)
result = self._do_command(AdminCommandNames.DOWNLOAD_JOB_COMPONENTS + " " + job_id)
meta = result[ResultKey.META]
location = meta.get(MetaKey.LOCATION)
return location

def abort_job(self, job_id: str):
"""Abort the specified job.

Expand Down
Loading