Source code for nvflare.apis.overseer_spec

# Copyright (c) 2022, NVIDIA CORPORATION.  All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from abc import ABC, abstractmethod
from dataclasses import dataclass, field

from requests import Response

from .fl_context import FLContext


[docs]@dataclass class SP: name: str = "" fl_port: str = "" admin_port: str = "" service_session_id: str = "" primary: bool = False props: dict = field(default_factory=dict)
[docs]class OverseerAgent(ABC): def __init__(self): self.overseer_info = {}
[docs] def initialize(self, fl_ctx: FLContext): pass
[docs] @abstractmethod def set_secure_context(self, ca_path: str, cert_path: str = "", prv_key_path: str = ""): pass
[docs] @abstractmethod def start(self, update_callback=None, conditional_cb=False): pass
[docs] @abstractmethod def pause(self): pass
[docs] @abstractmethod def resume(self): pass
[docs] @abstractmethod def end(self): pass
[docs] @abstractmethod def is_shutdown(self) -> bool: """Return whether the agent receives a shutdown request.""" pass
[docs] @abstractmethod def get_primary_sp(self) -> SP: """Return current primary service provider. If primary sp not available, such as not reported by SD, connection to SD not established yet the name and ports will be empty strings. """ pass
[docs] @abstractmethod def promote_sp(self, sp_end_point, headers=None) -> Response: pass
[docs] @abstractmethod def set_state(self, state) -> Response: pass