FEDOT

Форк
0
56 строк · 1.9 Кб
1
import os
2
from abc import abstractmethod
3
from datetime import timedelta
4
from typing import Optional, Type, TypeVar
5

6
from golem.core.log import default_log
7
from golem.utilities.serializable import Serializable
8

9
from fedot.core.utils import default_fedot_data_dir
10
from fedot.utilities.custom_errors import AbstractMethodNotImplementError
11

12
G = TypeVar('G', bound=Serializable)
13

14

15
class Client:
16
    """
17
    Base class for remote evaluation client. It allows to fit the pipelines in external system instead local one.
18
    """
19

20
    def __init__(self, connect_params: dict, exec_params: dict, output_path: Optional[str] = None):
21
        """
22
        :param connect_params: parameters for connection to remote server
23
        :param exec_params: params for remote task execution
24
        :param output_path: local path for temporary saving of downloaded pipelines
25
        """
26
        self.connect_params = connect_params
27
        self.exec_params = exec_params
28
        self.output_path = output_path if output_path else \
29
            os.path.join(default_fedot_data_dir(), 'remote_fit_results')
30
        self._logger = default_log(prefix='ClientLog')
31

32
    @abstractmethod
33
    def create_task(self, config: dict):
34
        """
35
        Create task for execution
36
        :param config - configuration of pipeline fitting
37
        :return: id of created task
38
        """
39
        raise AbstractMethodNotImplementError
40

41
    @abstractmethod
42
    def wait_until_ready(self) -> timedelta:
43
        """
44
        Delay execution until all remote tasks are ready
45
        :return: waiting time
46
        """
47
        raise AbstractMethodNotImplementError
48

49
    @abstractmethod
50
    def download_result(self, execution_id: int, result_cls: Type[G]) -> G:
51
        """
52
        :param execution_id: id of remote task
53
        :param result_cls: result
54
        :return: fitted pipeline downloaded from the remote server
55
        """
56
        raise AbstractMethodNotImplementError
57

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.