Example #1
0
    def __init__(self, name=None):
        """
        Object constructor.

        :param str|None name: The name of the command.
        """
        Command.__init__(self, name)
Example #2
0
def build_default_config(command: cleo.Command, base_config: dict = None):
    if base_config is None:
        base_config = {}
    config = base_config.copy()

    config.update({
        "global_unique_id": str(uuid.uuid4()),
        "pyklopp_version": __version__,
        "loaded_modules": None,
        "gpus_exclude": [],
        "gpu_choice":
        None,  # if None, then random uniform of all available is chosen
        "python_seed_initial": None,
        "python_seed_random_lower_bound": 0,
        "python_seed_random_upper_bound": 10000,
        "python_cwd": os.getcwd(),
        "hostname": socket.gethostname(),
        "time_config_start": time.time(),
        "save_path_base": None,
        "model_persistence_name": None,
        "config_persistence_name": "config.json",
        "argument_dataset": None,
    })

    all_options = command.option()
    all_arguments = command.argument()
    for prefix_name, keywords in zip(["option", "argument"],
                                     [all_options, all_arguments]):
        for kwname in keywords:
            config[prefix_name + "_" + kwname] = keywords[kwname]

    return config
Example #3
0
    def __init__(self):
        """
        Object constructor.
        """
        Command.__init__(self)

        self.__stat: bool = False
        """
        If True stat must be called for each file.
        """

        self._io: Optional[BackupPcCloneStyle] = None
        """
        The output style.
        """

        self.__dir_count: int = 0
        """
        The number of directories counted.
        """

        self.__file_count: int = 0
        """
        The number of file counted.
        """

        self.__start_time: float = 0
        """
Example #4
0
    def __init__(self, name=None):
        """
        Object constructor.

        :param str|None name: The name of the command.
        """
        Command.__init__(self, name)
Example #5
0
    def __init__(self, name: Optional[str] = None) -> None:
        """
        Object constructor.
        """
        Command.__init__(self, name)

        self._io: Optional[BackupPcCloneStyle] = None
        """
Example #6
0
    def __init__(self):
        """
        Object constructor.
        """
        Command.__init__(self)

        self._zmq_context = None
        """
        The ZMQ context.

        :type: Context
        """

        self.__end_points = {}
        """
Example #7
0
def save_paths_obtain_and_check(command: cleo.Command) -> (str, str):
    # Early check for save path
    save_path_base = None
    model_file_name = None
    if command.option("save"):
        save_path = str(command.option("save"))
        model_file_name = os.path.basename(save_path)
        # TODO check for model file name
        save_path_base = os.path.dirname(save_path)
        if len(save_path_base) < 1:
            raise ValueError(
                'You did not specify a valid save path. Given was "%s"' %
                save_path)
        if os.path.exists(os.path.join(save_path_base, model_file_name)):
            raise ValueError('Path "%s" already exists' % save_path_base)

        if not os.path.exists(save_path_base):
            os.makedirs(save_path_base)

    return save_path_base, model_file_name
Example #8
0
def write_file_and_print_table(cmd: Command, fa: FiniteAutomaton,
                               out: Optional[str]):
    alphabet = sorted(fa.alphabet)

    transitions = []

    for state in sorted(fa.states):
        line = [str_prev_state(state, fa)]

        for symbol in alphabet:
            new_state = fa.transitate(state, symbol)

            line.append(str_set_of_states(new_state))

        transitions.append(line)

    cmd.render_table(
        ['K \ Σ', *[str(s) for s in alphabet]],
        transitions,
    )

    if out is not None:
        path = fa_to_file(fa, out)
        cmd.info('Wrote finite automaton to {}'.format(path))
Example #9
0
 def __init__(self, configuration):
     """
     Constructor
     """
     Command.__init__(self)
     self.configuration = configuration
Example #10
0
 def __init__(self, configuration):
     """
     Constructor
     """
     Command.__init__(self)
     self.configuration = configuration