def get_main_external_repo(instance): return RepositoryLocation.from_handle( location_handle_from_python_file( python_file=file_relative_path(__file__, "setup.py"), attribute=main_repo_name(), working_directory=None, user_process_api=python_user_process_api_from_instance(instance), location_name=main_repo_location_name(), )).get_repository(main_repo_name())
def workspace_from_load_target(load_target, instance): check.inst_param(load_target, "load_target", WorkspaceLoadTarget) check.inst_param(instance, "instance", DagsterInstance) if isinstance(load_target, WorkspaceFileTarget): return load_workspace_from_yaml_paths( load_target.paths, python_user_process_api_from_instance(instance) ) elif isinstance(load_target, PythonFileTarget): return Workspace( [ location_handle_from_python_file( python_file=load_target.python_file, attribute=load_target.attribute, working_directory=load_target.working_directory, user_process_api=python_user_process_api_from_instance(instance), ) ] ) elif isinstance(load_target, ModuleTarget): return Workspace( [ location_handle_from_module_name( load_target.module_name, load_target.attribute, user_process_api=python_user_process_api_from_instance(instance), ) ] ) elif isinstance(load_target, GrpcServerTarget): return Workspace( [ RepositoryLocationHandle.create_grpc_server_location( port=load_target.port, socket=load_target.socket, host=load_target.host, ) ] ) elif isinstance(load_target, EmptyWorkspaceTarget): return Workspace([]) else: check.not_implemented("Unsupported: {}".format(load_target))
def test_manually_set_cli_api_instance(): with instance_for_test(overrides={"opt_in": { "local_servers": False }}) as instance: assert python_user_process_api_from_instance( instance) == UserProcessApi.CLI
def test_default_user_process_api(): with instance_for_test() as instance: assert python_user_process_api_from_instance( instance) == UserProcessApi.GRPC