def register_funcs(): fx = funcx.FuncXClient() container_uuid = fx.register_container("/project2/chard/skluzacek/ryan-data/globus-crawler.sif", "singularity") print(f"LOCAL_CRAWLER_FUNCX_UUID = \"{fx.register_function(run_local_crawler, container_uuid=container_uuid)}\"") print(f"GLOBUS_CRAWLER_FUNCX_UUID = \"{fx.register_function(run_globus_crawler, container_uuid=container_uuid)}\"") print(f"DECOMPRESSOR_FUNCX_UUID = \"{fx.register_function(run_decompressor, container_uuid=container_uuid)}\"") print(f"PROCESS_HEADER_FUNCX_UUID = \"{fx.register_function(process_job_headers, container_uuid=container_uuid)}\"")
def test_client_init_sets_addresses_by_env( monkeypatch, env, usage_method, explicit_params ): if env in (None, "production"): web_uri = "https://api2.funcx.org/v2" ws_uri = "wss://api2.funcx.org/ws/v2/" elif env in ("dev",): web_uri = "https://api.dev.funcx.org/v2" ws_uri = "wss://api.dev.funcx.org/ws/v2/" else: raise NotImplementedError # either pass the env as a param or set it in the environment kwargs = {} if usage_method == "param": kwargs["environment"] = env elif usage_method == "env_var": if env is not None: monkeypatch.setenv("FUNCX_SDK_ENVIRONMENT", env) else: raise NotImplementedError # create the client, either with just the input env or with explicit parameters # for explicit params, alter the expected URI(s) if explicit_params == "neither": client = funcx.FuncXClient(**kwargs) elif explicit_params == "web": web_uri = "http://localhost:5000" client = funcx.FuncXClient(funcx_service_address=web_uri, **kwargs) elif explicit_params == "ws": ws_uri = "ws://localhost:8081" client = funcx.FuncXClient(results_ws_uri=ws_uri, **kwargs) elif explicit_params == "both": web_uri = "http://localhost:5000" ws_uri = "ws://localhost:8081" client = funcx.FuncXClient( funcx_service_address=web_uri, results_ws_uri=ws_uri, **kwargs ) else: raise NotImplementedError # finally, confirm that the addresses were set correctly assert client.funcx_service_address == web_uri assert client.results_ws_uri == ws_uri
import funcx fxc = funcx.FuncXClient() print(fxc.base_url) def hello_world(): return "Hello World!" func_uuid = fxc.register_function(hello_world) print(func_uuid) tutorial_endpoint = '68bade94-bf58-4a7a-bfeb-9c6a61fa5443' res = fxc.run(endpoint_id=tutorial_endpoint, function_id=func_uuid) print(res) import time while True: try: res = fxc.get_result(res) print(res) except Exception as e: print(e) time.sleep(2)