def test_bad_load(): with _default_instance() as instance: instance = DagsterInstance.get() working_directory = os.path.dirname(__file__) loadable_target_origin = LoadableTargetOrigin( executable_path=sys.executable, python_file=__file__, attribute="doesnt_exist", working_directory=working_directory, ) repo_origin = ExternalRepositoryOrigin( ManagedGrpcPythonEnvRepositoryLocationOrigin( loadable_target_origin=loadable_target_origin ), "doesnt_exist", ) schedule_origin = repo_origin.get_job_origin("also_doesnt_exist") result = sync_launch_scheduled_execution(schedule_origin) assert isinstance(result, ScheduledExecutionFailed) assert "doesnt_exist not found at module scope in file" in result.errors[0].to_string() ticks = instance.get_job_ticks(schedule_origin.get_id()) assert ticks[0].status == JobTickStatus.FAILURE assert "doesnt_exist not found at module scope in file" in ticks[0].error.message
def test_grpc_server_down(): with _default_instance() as instance: down_grpc_repo_origin = ExternalRepositoryOrigin( GrpcServerRepositoryLocationOrigin( host="localhost", port=find_free_port(), socket=None, ), repository_name="down_repo", ) down_grpc_schedule_origin = down_grpc_repo_origin.get_job_origin( "down_schedule") instance = DagsterInstance.get() result = sync_launch_scheduled_execution(down_grpc_schedule_origin, "US/Eastern") assert isinstance(result, ScheduledExecutionFailed) assert "failed to connect to all addresses" in result.errors[ 0].to_string() ticks = instance.get_job_ticks(down_grpc_schedule_origin.get_id()) assert ticks[0].status == JobTickStatus.FAILURE assert "failed to connect to all addresses" in ticks[0].error.message
def python_schedule_origin(schedule_name): loadable_target_origin = LoadableTargetOrigin( executable_path=sys.executable, python_file=__file__, attribute="the_repo" ) repo_origin = ExternalRepositoryOrigin( ManagedGrpcPythonEnvRepositoryLocationOrigin(loadable_target_origin=loadable_target_origin), "the_repo", ) yield repo_origin.get_job_origin(schedule_name)
def grpc_schedule_origin(schedule_name): loadable_target_origin = LoadableTargetOrigin( executable_path=sys.executable, python_file=__file__, attribute="the_repo" ) server_process = GrpcServerProcess(loadable_target_origin=loadable_target_origin) with server_process.create_ephemeral_client() as api_client: repo_origin = ExternalRepositoryOrigin( GrpcServerRepositoryLocationOrigin( host=api_client.host, port=api_client.port, socket=api_client.socket, ), repository_name="the_repo", ) yield repo_origin.get_job_origin(schedule_name) server_process.wait()