Skip to content

Commit 97f8910

Browse files
committed
Merge branch 'main' into adds-ruff
2 parents 34504dc + f1e6450 commit 97f8910

File tree

142 files changed

+3883
-2951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+3883
-2951
lines changed

.github/workflows/CI-codeql.yml

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
name: "CI | CodeQL"
1313

1414
on:
15-
push:
16-
branches: ["main"]
1715
pull_request:
1816
# The branches below must be a subset of the branches above
1917
branches: ["main"]

.github/workflows/CI-pylint.yml

-37
This file was deleted.

.github/workflows/CI-pytests.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ name: CI | Unit Tests
22

33
on:
44
push:
5-
branches-ignore:
6-
- main-ci
7-
- release
5+
branches:
6+
- main
87

98
pull_request:
109
branches:
@@ -33,4 +32,4 @@ jobs:
3332
pip install '.[test]'
3433
3534
- name: Run Tests
36-
run: pytest --cov-config=.coveragerc --timeout=120 --timeout_method=thread --cov=runpod --cov-report=xml --cov-report=term-missing --cov-fail-under=98 -W error -p no:cacheprovider -p no:unraisableexception
35+
run: pytest

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test_logging.py
88
/example_project
99
IGNORE.py
1010
/quick-test
11+
.DS_Store
1112

1213
# Byte-compiled / optimized / DLL files
1314
__pycache__/

examples/api/create_endpoint.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
try:
99

1010
new_template = runpod.create_template(
11-
name="test",
12-
image_name="runpod/base:0.4.4",
13-
is_serverless=True
11+
name="test", image_name="runpod/base:0.4.4", is_serverless=True
1412
)
1513

1614
print(new_template)
@@ -21,7 +19,7 @@
2119
gpu_ids="AMPERE_16",
2220
workers_min=0,
2321
workers_max=1,
24-
flashboot=True
22+
flashboot=True,
2523
)
2624

2725
print(new_endpoint)

examples/api/create_template.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
try:
99

10-
new_template = runpod.create_template(
11-
name="test",
12-
image_name="runpod/base:0.1.0"
13-
)
10+
new_template = runpod.create_template(name="test", image_name="runpod/base:0.1.0")
1411

1512
print(new_template)
1613

examples/api/get_endpoints.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
""" Get all endpoints from the API """
22

3-
43
import runpod
54

65
endpoints = runpod.get_endpoints()

examples/endpoints/asyncio_job_request.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
import asyncio
66

77
import runpod
8-
from runpod import http_client, AsyncioEndpoint, AsyncioJob
8+
from runpod import AsyncioEndpoint, AsyncioJob, http_client
99

10-
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # For Windows Users
10+
asyncio.set_event_loop_policy(
11+
asyncio.WindowsSelectorEventLoopPolicy()
12+
) # For Windows Users
1113

1214
runpod.api_key = "YOUR_API_KEY"
1315

1416

1517
async def main():
16-
'''
18+
"""
1719
Function to run the example.
18-
'''
20+
"""
1921
async with http_client.AsyncClientSession() as session:
2022
# Invoke API
2123
payload = {}
@@ -34,4 +36,5 @@ async def main():
3436
# Print output
3537
print(output)
3638

39+
3740
asyncio.run(main())

examples/endpoints/run.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
'''
1+
"""
22
Example of calling an endpoint using the RunPod Python Language Library.
3-
'''
3+
"""
44

55
import runpod
66

@@ -9,11 +9,9 @@
99

1010
endpoint = runpod.Endpoint("sdxl") # Where "sdxl" is the endpoint ID
1111

12-
run_request = endpoint.run({
13-
"input": {
14-
"prompt": "a photo of a horse the size of a Boeing 787"
15-
}
16-
})
12+
run_request = endpoint.run(
13+
{"input": {"prompt": "a photo of a horse the size of a Boeing 787"}}
14+
)
1715

1816
# Check the status of the run request
1917
print(run_request.status())

examples/endpoints/run_sync.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
'''
1+
"""
22
Example of calling an endpoint using the RunPod Python Language Library.
3-
'''
3+
"""
44

55
import runpod
66

@@ -12,12 +12,8 @@
1212
try:
1313
# Run the endpoint synchronously, blocking until the endpoint run is complete.
1414
run_request = endpoint.run_sync(
15-
{
16-
"input": {
17-
"prompt": "a photo of a horse the size of a Boeing 787"
18-
}
19-
},
20-
timeout=60 # Seconds
15+
{"input": {"prompt": "a photo of a horse the size of a Boeing 787"}},
16+
timeout=60, # Seconds
2117
)
2218

2319
print(run_request)

examples/endpoints/streaming.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
endpoint = runpod.Endpoint("gwp4kx5yd3nur1")
99

10-
run_request = endpoint.run({
11-
"input": {
12-
"mock_return": ["a", "b", "c", "d", "e", "f", "g"],
13-
"mock_delay": 1,
10+
run_request = endpoint.run(
11+
{
12+
"input": {
13+
"mock_return": ["a", "b", "c", "d", "e", "f", "g"],
14+
"mock_delay": 1,
15+
}
1416
}
15-
})
17+
)
1618

1719
for output in run_request.stream():
1820
print(output)

examples/graphql_wrapper.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
''''
1+
"""'
22
GraphQL wrapper for the RunPod API
3-
'''
3+
"""
44

55
import time
6-
import runpod
76

7+
import runpod
88

99
runpod.api_key = "YOUR_RUNPOD_API_KEY"
1010

examples/serverless/concurrent_handler.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,24 @@
55

66
# ---------------------------------- Handler --------------------------------- #
77
async def async_generator_handler(job):
8-
'''
8+
"""
99
Async generator type handler.
10-
'''
10+
"""
1111
return job
1212

1313

14-
runpod.serverless.start({
15-
"handler": async_generator_handler,
16-
})
14+
# --------------------------- Concurrency Modifier --------------------------- #
15+
def concurrency_modifier(current_concurrency=1):
16+
"""
17+
Concurrency modifier.
18+
"""
19+
desired_concurrency = current_concurrency
20+
21+
# Do some logic to determine the desired concurrency.
22+
23+
return desired_concurrency
24+
25+
26+
runpod.serverless.start(
27+
{"handler": async_generator_handler, "concurrency_modifier": concurrency_modifier}
28+
)

examples/serverless/logger.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
""" Example of using the RunPodLogger class. """""
1+
""" Example of using the RunPodLogger class. """ ""
22

33
import runpod
44

5-
JOB_ID = '1234567890'
5+
JOB_ID = "1234567890"
66
log = runpod.RunPodLogger()
77

88

9-
log.debug('A debug message')
10-
log.info('An info message')
11-
log.warn('A warning message')
12-
log.error('An error message')
9+
log.debug("A debug message")
10+
log.info("An info message")
11+
log.warn("A warning message")
12+
log.error("An error message")
1313

1414
# Output:
1515
# DEBUG | A debug message
@@ -18,10 +18,10 @@
1818
# ERROR | An error message
1919

2020

21-
log.debug('A debug message', request_id=JOB_ID)
22-
log.info('An info message', request_id=JOB_ID)
23-
log.warn('A warning message', request_id=JOB_ID)
24-
log.error('An error message', request_id=JOB_ID)
21+
log.debug("A debug message", request_id=JOB_ID)
22+
log.info("An info message", request_id=JOB_ID)
23+
log.warn("A warning message", request_id=JOB_ID)
24+
log.error("An error message", request_id=JOB_ID)
2525

2626
# Output:
2727
# {"requestId": "1234567890", "message": "A debug message", "level": "DEBUG"}

examples/serverless/simple_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def handler(job):
11-
""" Simple handler """
11+
"""Simple handler"""
1212
job_input = job["input"]
1313

1414
return f"Hello {job_input['name']}!"

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[pytest]
2-
addopts = --durations=10 --cov-config=.coveragerc --timeout=120 --timeout_method=thread --cov=runpod --cov-report=xml --cov-report=term-missing --cov-fail-under=98 -W error -p no:cacheprovider -p no:unraisableexception
2+
addopts = --durations=10 --cov-config=.coveragerc --timeout=120 --timeout_method=thread --cov=runpod --cov-report=xml --cov-report=term-missing --cov-fail-under=90 -W error -p no:cacheprovider -p no:unraisableexception
33
python_files = tests.py test_*.py *_test.py
44
norecursedirs = venv *.egg-info .git build

runpod/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
""" Allows runpod to be imported as a module. """
22

3-
import os
43
import logging
4+
import os
55

66
from . import serverless
77
from .api.ctl_commands import (
88
create_container_registry_auth,
99
create_endpoint,
1010
create_pod,
1111
create_template,
12+
delete_container_registry_auth,
1213
get_endpoints,
1314
get_gpu,
1415
get_gpus,
@@ -18,6 +19,7 @@
1819
resume_pod,
1920
stop_pod,
2021
terminate_pod,
22+
update_container_registry_auth,
2123
update_endpoint_template,
2224
update_user_settings,
2325
)
@@ -42,7 +44,9 @@
4244
else:
4345
api_key = None # pylint: disable=invalid-name
4446

45-
endpoint_url_base = os.environ.get("RUNPOD_ENDPOINT_BASE_URL", "https://api.runpod.ai/v2") # pylint: disable=invalid-name
47+
endpoint_url_base = os.environ.get(
48+
"RUNPOD_ENDPOINT_BASE_URL", "https://api.runpod.ai/v2"
49+
) # pylint: disable=invalid-name
4650

4751

4852
# --------------------------- Force Logging Levels --------------------------- #

runpod/api/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
''' Allows api_wrapper to be imported as a module.'''
1+
""" Allows api_wrapper to be imported as a module."""

runpod/api/ctl_commands.py

+36
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
RunPod | API Wrapper | CTL Commands
33
"""
4+
45
# pylint: disable=too-many-arguments,too-many-locals
56

67
from typing import Optional
@@ -370,3 +371,38 @@ def create_container_registry_auth(name: str, username: str, password: str):
370371
)
371372
)
372373
return raw_response["data"]["saveRegistryAuth"]
374+
375+
376+
def update_container_registry_auth(registry_auth_id: str, username: str, password: str):
377+
"""
378+
Update a container registry authentication.
379+
380+
Args:
381+
registry_auth_id (str): The id of the container registry authentication
382+
username (str): The username for authentication.
383+
password (str): The password for authentication.
384+
385+
Returns:
386+
dict: The response data containing the updated container registry authentication.
387+
"""
388+
raw_response = run_graphql_query(
389+
container_register_auth_mutations.update_container_registry_auth(
390+
registry_auth_id, username, password
391+
)
392+
)
393+
return raw_response["data"]["updateRegistryAuth"]
394+
395+
396+
def delete_container_registry_auth(registry_auth_id: str):
397+
"""
398+
Delete a container registry authentication.
399+
400+
Args:
401+
registry_auth_id (str): The id of the container registry authentication
402+
"""
403+
raw_response = run_graphql_query(
404+
container_register_auth_mutations.delete_container_registry_auth(
405+
registry_auth_id
406+
)
407+
)
408+
return raw_response["data"]["deleteRegistryAuth"]

0 commit comments

Comments
 (0)