-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from runpod/cli-stream-fix
Cli stream fix
- Loading branch information
Showing
13 changed files
with
102 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Retrieve handler info. """ | ||
|
||
import inspect | ||
from typing import Callable | ||
|
||
def is_generator(handler: Callable) -> bool: | ||
"""Check if handler is a generator function. """ | ||
return inspect.isgeneratorfunction(handler) or inspect.isasyncgenfunction(handler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" Unit tests for the handler module. | ||
""" | ||
import unittest | ||
|
||
from runpod.serverless.modules.rp_handler import is_generator | ||
|
||
|
||
class TestIsGenerator(unittest.TestCase): | ||
"""Tests for the is_generator function.""" | ||
|
||
def test_regular_function(self): | ||
"""Test that a regular function is not a generator.""" | ||
def regular_func(): | ||
return "I'm a regular function!" | ||
self.assertFalse(is_generator(regular_func)) | ||
|
||
def test_generator_function(self): | ||
"""Test that a generator function is a generator.""" | ||
def generator_func(): | ||
yield "I'm a generator function!" | ||
self.assertTrue(is_generator(generator_func)) | ||
|
||
def test_async_function(self): | ||
"""Test that an async function is not a generator.""" | ||
async def async_func(): | ||
return "I'm an async function!" | ||
self.assertFalse(is_generator(async_func)) | ||
|
||
def test_async_generator_function(self): | ||
"""Test that an async generator function is a generator.""" | ||
async def async_gen_func(): | ||
yield "I'm an async generator function!" | ||
self.assertTrue(is_generator(async_gen_func)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters