Skip to content

Commit 98baddc

Browse files
committed
fix: add back nest_asyncio
1 parent 90ba6fe commit 98baddc

4 files changed

Lines changed: 41 additions & 33 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ runpod = "runpod.cli.entry:runpod_cli"
5353
[project.optional-dependencies]
5454
test = [
5555
"asynctest",
56+
"nest_asyncio",
5657
"pylint",
5758
"pytest",
5859
"pytest-cov",

setup.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
extras_require = {
1717
'test': [
18-
'asynctest',
18+
'asynctest',
19+
'nest_asyncio',
1920
'pylint',
2021
'pytest',
2122
'pytest-cov',
@@ -27,44 +28,44 @@
2728
if __name__ == "__main__":
2829

2930
setup(
30-
name = 'runpod',
31+
name='runpod',
3132

32-
use_scm_version = True,
33+
use_scm_version=True,
3334

34-
setup_requires = [
35+
setup_requires=[
3536
'setuptools>=45',
3637
'setuptools_scm',
3738
'wheel'
3839
],
3940

40-
install_requires = install_requires,
41+
install_requires=install_requires,
4142

42-
extras_require = extras_require,
43+
extras_require=extras_require,
4344

44-
packages = find_packages(),
45+
packages=find_packages(),
4546

46-
python_requires = '>=3.8',
47+
python_requires='>=3.8',
4748

48-
description = '🐍 | Python library for RunPod API and serverless worker SDK.',
49+
description='🐍 | Python library for RunPod API and serverless worker SDK.',
4950

50-
long_description = long_description,
51+
long_description=long_description,
5152

52-
long_description_content_type = 'text/markdown',
53+
long_description_content_type='text/markdown',
5354

54-
author = 'RunPod',
55+
author='RunPod',
5556

56-
author_email = 'engineer@runpod.io',
57+
author_email='engineer@runpod.io',
5758

58-
url = 'https://runpod.io',
59+
url='https://runpod.io',
5960

60-
project_urls = {
61+
project_urls={
6162
'Documentation': 'https://docs.runpod.io',
6263
'Source': 'https://github.com/runpod/runpod-python',
6364
'Bug Tracker': 'https://github.com/runpod/runpod-python/issues',
6465
'Changelog': 'https://github.com/runpod/runpod-python/blob/main/CHANGELOG.md'
6566
},
6667

67-
classifiers = [
68+
classifiers=[
6869
'Environment :: Web Environment',
6970
'Intended Audience :: Developers',
7071
'License :: OSI Approved :: MIT License',
@@ -75,15 +76,15 @@
7576
'Topic :: Internet :: WWW/HTTP :: Dynamic Content'
7677
],
7778

78-
include_package_data = True,
79+
include_package_data=True,
7980

80-
entry_points = {
81+
entry_points={
8182
'console_scripts': [
8283
'runpod = runpod.cli.entry:runpod_cli'
8384
]
8485
},
8586

86-
keywords = ['runpod', 'ai', 'gpu', 'serverless', 'SDK', 'API', 'python', 'library'],
87+
keywords=['runpod', 'ai', 'gpu', 'serverless', 'SDK', 'API', 'python', 'library'],
8788

88-
license = 'MIT'
89+
license='MIT'
8990
)

tests/test_serverless/test_modules/test_fastapi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def test_start_serverless_with_realtime(self):
5050

5151
self.assertTrue(mock_uvicorn.run.called)
5252

53+
os.environ.pop("RUNPOD_REALTIME_PORT")
54+
os.environ.pop("RUNPOD_ENDPOINT_ID")
55+
5356
@pytest.mark.asyncio
5457
def test_run(self):
5558
'''

tests/test_serverless/test_worker.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
from unittest.mock import patch, mock_open, Mock, MagicMock
88

99
from unittest import IsolatedAsyncioTestCase
10+
import nest_asyncio
1011

1112
import runpod
1213
from runpod._version import __version__ as runpod_version
1314
from runpod.serverless.modules.rp_logger import RunPodLogger
1415
from runpod.serverless import _signal_handler
1516

17+
nest_asyncio.apply()
18+
1619

1720
class TestWorker(IsolatedAsyncioTestCase):
1821
""" Tests for runpod | serverless| worker """
@@ -28,9 +31,8 @@ def setUp(self):
2831
"test_input": None,
2932
}
3033
}
31-
os.environ["RUNPOD_REALTIME_PORT"] = '0'
3234

33-
async def test_get_auth_header(self):
35+
def test_get_auth_header(self):
3436
'''
3537
Test _get_auth_header
3638
'''
@@ -43,7 +45,7 @@ async def test_get_auth_header(self):
4345
'User-Agent': f'RunPod-Python-SDK/{runpod_version} ({os_info}) Language/Python {platform.python_version()}' # pylint: disable=line-too-long
4446
}
4547

46-
async def test_is_local(self):
48+
def test_is_local(self):
4749
'''
4850
Test _is_local
4951
'''
@@ -64,11 +66,12 @@ def test_start(self):
6466
'''
6567
with patch("builtins.open", mock_open(read_data='{"input":{"number":1}}')) as mock_file, \
6668
self.assertRaises(SystemExit):
69+
6770
runpod.serverless.start({"handler": self.mock_handler})
6871

6972
assert mock_file.called
7073

71-
async def test_is_local_testing(self):
74+
def test_is_local_testing(self):
7275
'''
7376
Test _is_local_testing
7477
'''
@@ -103,7 +106,7 @@ def test_local_api(self):
103106

104107
@patch('runpod.serverless.log')
105108
@patch('runpod.serverless.sys.exit')
106-
async def test_signal_handler(self, mock_exit, mock_logger):
109+
def test_signal_handler(self, mock_exit, mock_logger):
107110
'''
108111
Test signal handler.
109112
'''
@@ -188,7 +191,7 @@ def setUp(self):
188191
@patch("runpod.serverless.worker.stream_result")
189192
@patch("runpod.serverless.worker.send_result")
190193
# pylint: disable=too-many-arguments
191-
def test_run_worker(
194+
async def test_run_worker(
192195
self, mock_send_result, mock_stream_result, mock_run_job, mock_get_job, mock_session):
193196
'''
194197
Test run_worker with synchronous handler.
@@ -219,7 +222,7 @@ def test_run_worker(
219222
@patch("runpod.serverless.worker.run_job")
220223
@patch("runpod.serverless.worker.stream_result")
221224
@patch("runpod.serverless.worker.send_result")
222-
def test_run_worker_generator_handler(
225+
async def test_run_worker_generator_handler(
223226
self, mock_send_result, mock_stream_result, mock_run_job,
224227
mock_get_job):
225228
'''
@@ -251,7 +254,7 @@ def test_run_worker_generator_handler(
251254
@patch("runpod.serverless.worker.run_job")
252255
@patch("runpod.serverless.worker.stream_result")
253256
@patch("runpod.serverless.worker.send_result")
254-
def test_run_worker_generator_handler_exception(
257+
async def test_run_worker_generator_handler_exception(
255258
self, mock_send_result, mock_stream_result, mock_run_job,
256259
mock_get_job):
257260
'''
@@ -283,7 +286,7 @@ def test_run_worker_generator_handler_exception(
283286
@patch("runpod.serverless.worker.run_job")
284287
@patch("runpod.serverless.worker.stream_result")
285288
@patch("runpod.serverless.worker.send_result")
286-
def test_run_worker_generator_aggregate_handler(
289+
async def test_run_worker_generator_aggregate_handler(
287290
self, mock_send_result, mock_stream_result, mock_run_job,
288291
mock_get_job):
289292
'''
@@ -319,7 +322,7 @@ def test_run_worker_generator_aggregate_handler(
319322
@patch("runpod.serverless.worker.stream_result")
320323
@patch("runpod.serverless.worker.send_result")
321324
# pylint: disable=too-many-arguments
322-
def test_run_worker_concurrency(
325+
async def test_run_worker_concurrency(
323326
self, mock_send_result, mock_stream_result, mock_run_job, mock_get_job, mock_session):
324327
'''
325328
Test run_worker with synchronous handler.
@@ -358,7 +361,7 @@ def concurrency_modifier(current_concurrency):
358361
@patch("runpod.serverless.worker.stream_result")
359362
@patch("runpod.serverless.worker.send_result")
360363
# pylint: disable=too-many-arguments
361-
def test_run_worker_multi_processing(
364+
async def test_run_worker_multi_processing(
362365
self, mock_send_result, mock_stream_result, mock_run_job, mock_get_job, mock_session):
363366
'''
364367
Test run_worker with multi processing enabled, both async and generator handler.
@@ -417,7 +420,7 @@ def test_run_worker_multi_processing(
417420

418421
@patch("runpod.serverless.modules.rp_scale.get_job")
419422
@patch("runpod.serverless.worker.run_job")
420-
def test_run_worker_multi_processing_scaling_up(
423+
async def test_run_worker_multi_processing_scaling_up(
421424
self, mock_run_job, mock_get_job):
422425
'''
423426
Test run_worker with multi processing enabled, the scale-up and scale-down
@@ -463,7 +466,7 @@ def mock_is_alive():
463466
runpod.serverless.start(config)
464467

465468
# Test with sls-core
466-
def test_run_worker_with_sls_core(self):
469+
async def test_run_worker_with_sls_core(self):
467470
'''
468471
Test run_worker with sls-core.
469472
'''

0 commit comments

Comments
 (0)