Exemple #1
0
    def __update_configs(self):
        if self.configs['path'] is None:
            self.path = None
            self.experiments = None
            self.data_path = None
        else:
            self.path = Path(self.configs['path'])
            self.data_path = (self.path / self.configs['data_path']).resolve()
            self.experiments = (self.path /
                                self.configs['experiments_path']).resolve()

        self.check_repo_dirty = self.configs['check_repo_dirty']
        self.indicators = self.configs['indicators']
        if self.configs['web_api']:
            web_api_url = self.configs['web_api']
            if web_api_url[0:4] != 'http':
                web_api_url = f"https://api.labml.ai/api/v1/track?labml_token={web_api_url}&"
            is_default = web_api_url == self.__default_config()['web_api']
            # if is_default:
            #     from labml.internal.computer.configs import computer_singleton
            #     if not computer_singleton().web_api.is_default:
            #         web_api_url = computer_singleton().web_api.url
            self.web_api = WebAPIConfigs(
                url=web_api_url,
                frequency=self.configs['web_api_frequency'],
                verify_connection=self.configs['web_api_verify_connection'],
                open_browser=self.configs['web_api_open_browser'],
                is_default=is_default)
        else:
            self.web_api = None
Exemple #2
0
    def __load_configs(self):
        if self.config_folder.is_file():
            self.config_folder.unlink()

        if not self.config_folder.exists():
            self.config_folder.mkdir(parents=True)

        if not self.projects_folder.exists():
            self.projects_folder.mkdir()

        if not self.app_folder.exists():
            self.app_folder.mkdir()

        if not self.runs_cache.exists():
            self.runs_cache.mkdir()

        if self.configs_file.exists():
            with open(str(self.configs_file)) as f:
                config = util.yaml_load(f.read())
                if config is None:
                    config = {}
        else:
            logger.log([('~/labml/configs.yaml', Text.value),
                        ' does not exist. Creating ',
                        (str(self.configs_file), Text.meta)])
            config = {}

        if 'uuid' not in config:
            from uuid import uuid1
            config['uuid'] = uuid1().hex
            with open(str(self.configs_file), 'w') as f:
                f.write(util.yaml_dump(config))

        default_config = self.__default_config()
        for k, v in default_config.items():
            if k not in config:
                config[k] = v

        self.uuid = config['uuid']
        web_api_url = config['web_api']
        if web_api_url[0:4] != 'http':
            web_api_url = f"https://api.labml.ai/api/v1/computer?labml_token={web_api_url}&"
        self.web_api = WebAPIConfigs(
            url=web_api_url,
            frequency=config['web_api_frequency'],
            verify_connection=config['web_api_verify_connection'],
            open_browser=config['web_api_open_browser'],
            is_default=web_api_url == self.__default_config()['web_api'])
        self.web_api_sync = config['web_api_sync']
        self.web_api_polling = config['web_api_polling']

        self.tensorboard_port = config['tensorboard_port']
        self.tensorboard_visible_port = config['tensorboard_visible_port']
        self.tensorboard_host = config['tensorboard_host']
        self.tensorboard_protocol = config['tensorboard_protocol']