def test_with_funcx_config(self, mocker): mock_interchange = mocker.patch( "funcx_endpoint.endpoint.endpoint_manager.EndpointInterchange") mock_interchange.return_value.start.return_value = None mock_interchange.return_value.stop.return_value = None mock_optionals = {} mock_optionals["interchange_address"] = "127.0.0.1" mock_funcx_config = {} mock_funcx_config["endpoint_address"] = "127.0.0.1" manager = EndpointManager(funcx_dir=os.getcwd()) manager.name = "test" config_dir = os.path.join(manager.funcx_dir, "mock_endpoint") mock_optionals["logdir"] = config_dir manager.funcx_config = mock_funcx_config manager.configure_endpoint("mock_endpoint", None) endpoint_config = SourceFileLoader( "config", os.path.join(config_dir, "config.py")).load_module() funcx_client_options = {} manager.daemon_launch( "mock_endpoint_uuid", config_dir, "mock_keys_dir", endpoint_config, None, funcx_client_options, None, ) mock_interchange.assert_called_with( endpoint_config.config, endpoint_id="mock_endpoint_uuid", keys_dir="mock_keys_dir", endpoint_dir=config_dir, endpoint_name=manager.name, reg_info=None, funcx_client_options=funcx_client_options, results_ack_handler=None, **mock_optionals, )
def main( ctx: typer.Context, _: bool = typer.Option(None, "--version", "-v", callback=version_callback, is_eager=True), debug: bool = typer.Option(False, "--debug", "-d"), config_dir: str = typer.Option( os.path.join(pathlib.Path.home(), ".funcx"), "--config_dir", "-c", help="override default config dir", ), ): # Note: no docstring here; the docstring for @app.callback is used as a help # message for overall app. # # Sets up global variables in the State wrapper (debug flag, config dir, default # config file). # # For commands other than `init`, we ensure the existence of the config directory # and file. setup_logging(debug=debug) log.debug("Command: %s", ctx.invoked_subcommand) global manager manager = EndpointManager(funcx_dir=config_dir, debug=debug) # Otherwise, we ensure that configs exist if not os.path.exists(manager.funcx_config_file): log.info( "No existing configuration found at %s. Initializing...", manager.funcx_config_file, ) manager.init_endpoint() log.debug(f"Loading config files from {manager.funcx_dir}") funcx_config = SourceFileLoader("global_config", manager.funcx_config_file).load_module() manager.funcx_config = funcx_config.global_options