[Serve] Unskipped tests in test_pipeline.py (#21484)

This commit is contained in:
Gagandeep Singh 2022-01-13 03:26:50 +05:30 committed by GitHub
parent 188324c5c7
commit 13f20e5e1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,39 +88,42 @@ def test_basic_class(execution_mode, shared_ray_instance):
assert greeter.call("Theodore") == "Top of the morning Theodore!"
@pytest.mark.skipif(sys.platform == "win32", reason="File handling.")
@pytest.mark.parametrize("execution_mode", ALL_EXECUTION_MODES)
@enable_local_execution_mode_only
def test_class_constructor_not_called_until_deployed(execution_mode,
shared_ray_instance):
"""Constructor should only be called after .deploy()."""
with tempfile.NamedTemporaryFile("w") as tmp:
tmp = tempfile.NamedTemporaryFile("w+", suffix=".tmp", delete=False)
tmp.close()
@pipeline.step(execution_mode=execution_mode)
class FileWriter:
def __init__(self, tmpfile: str, msg: str):
with open(tmpfile, "w") as f:
f.write(msg)
f.flush()
@pipeline.step(execution_mode=execution_mode)
class FileWriter:
def __init__(self, tmpfile_name, msg: str):
with open(tmpfile_name, "w") as tmpfile:
tmpfile.write(msg)
tmpfile.flush()
def __call__(self, arg: str):
return arg
def __call__(self, arg: str):
return arg
msg = "hello"
msg = "hello"
def constructor_called():
with open(tmp.name, "r") as f:
return f.read() == msg
def constructor_called():
with open(tmp.name, "r") as f:
ret = f.readline() == msg
return ret
file_writer = FileWriter(tmp.name, msg)
assert not constructor_called()
file_writer = FileWriter(tmp.name, msg)
assert not constructor_called()
writer_pipeline = file_writer(pipeline.INPUT)
assert not constructor_called()
writer_pipeline = file_writer(pipeline.INPUT)
assert not constructor_called()
assert writer_pipeline.deploy().call("hi") == "hi"
assert constructor_called()
assert writer_pipeline.deploy().call("hi") == "hi"
assert constructor_called()
os.unlink(tmp.name)
@pytest.mark.parametrize("execution_mode", ALL_EXECUTION_MODES)