def load_module(inference_state, dotted_name, **kwargs): # Temporary, some tensorflow builtins cannot be loaded, so it's tried again # and again and it's really slow. if dotted_name.startswith('tensorflow.'): return None access_path = inference_state.compiled_subprocess.load_module(dotted_name=dotted_name, **kwargs) if access_path is None: return None return create_from_access_path(inference_state, access_path)
def create_simple_object(inference_state, obj): """ Only allows creations of objects that are easily picklable across Python versions. """ assert type(obj) in (int, float, str, bytes, slice, complex, bool), repr(obj) compiled_value = create_from_access_path( inference_state, inference_state.compiled_subprocess.create_simple_object(obj)) return ExactValue(compiled_value)
def create_compiled_object(inference_state): return lambda obj: create_from_access_path( inference_state, inference_state.compiled_subprocess.create_simple_object(obj))