Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test tqdm stream redirection #2067

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build:
python_version: "3.11"
python_packages:
- "tqdm==4.66.6"
predict: "predict.py:Predictor"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from cog import BasePredictor
import tqdm
import time


class Predictor(BasePredictor):

def predict(self) -> str:
print("Starting Predict:")
for i in tqdm.tqdm(range(10), total=10):
time.sleep(i)
return "Hello World"
15 changes: 15 additions & 0 deletions test-integration/test_integration/test_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,18 @@ def test_predict_with_subprocess_in_setup(fixture_name):
assert response.status_code == 200, str(response)

assert busy_count < 10


def test_file_logging_stream_drain(tmpdir_factory):
project_dir = Path(__file__).parent / "fixtures/file-logging-stream-drain-project"
out_dir = pathlib.Path(tmpdir_factory.mktemp("project"))
shutil.copytree(project_dir, out_dir, dirs_exist_ok=True)
cmd = ["cog", "--debug", "predict"]

subprocess.run(
cmd,
cwd=out_dir,
check=True,
text=True,
timeout=DEFAULT_TIMEOUT,
)
Loading