Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

### Bug Fixes

* SDK and CLI requests reject unfollowed redirects. Apps errors sanitize credentials in redirect diagnostics, including artifact upload failures.
* Account login is available through `runpod.auth.login` and `runpod.apps.auth`. `LoginError` is catchable as either `AuthenticationError` or `AppError`. CLI helpers are available under both `runpod.cli` and `runpod.rp_cli`.
* Assigning a custom `runpod.endpoint_url_base` takes precedence over the endpoint environment variable.
* [BREAKING] `rp login` asks you to paste the API key shown in the console after approval. It no longer collects the key by polling the auth request, and it fails fast without an interactive terminal.
* Task calls support indefinite execution with bounded interruption cleanup. Failed deletion retains the pod ID for recovery.
* Network volume creation intersects catalog storage support with every sharing resource's hardware stock and datacenter constraints. Unsupported explicit pins fail before creation; existing volumes retain their authoritative IDs and datacenters.
Expand Down
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ This project adheres to the [PEP 8](https://www.python.org/dev/peps/pep-0008/) c

Before submitting a pull request, please make sure your changes pass all tests. New features should include additional unit tests validating the changes.

### HTTP Requests

Use `Route` templates for paths and the shared clients in `runpod.api` for HTTP requests. Route parameters are escaped, and service bases are configured in `runpod.api.routes`. Keep a client context open across related requests to reuse its connection pool.

```python
from runpod.api.rest import AsyncRESTClient
from runpod.api.routes import Route

async with AsyncRESTClient() as client:
pod = await client.request(Route("GET", "/v2/pods/{pod_id}", pod_id=pod_id))
```

`RESTClient` provides the synchronous equivalent. Both clients apply account authentication and bounded rate-limit waits. `HTTPClient` and `SyncHTTPClient` in `runpod.api.http` handle raw transport for GraphQL, streams, worker requests, and uploads. These raw clients require explicit authentication headers. Their `stream()` contexts expose responses for protocol-specific handling and release them on exit. A supplied session remains owned by its caller.

Account login and credential storage belong in `runpod.auth`. CLI commands belong in `runpod.cli`.

## Getting Help

If you have any questions or need help with contributing, feel free to reach out on the [issue tracker](https://github.com/runpod/runpod-python/issues) or open a new issue. We're here to help!
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ rp flash dev main.py # live dev session: edit, re-run, logs stream back
rp flash deploy # deploy production endpoints
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge of main in e7255b5 drops the paragraph main added in #796: "Recurring schedules are not supported by runpod.apps. For periodic jobs, use an external scheduler to invoke a deployed queue function with .spawn()." README was not a conflicted file, so the auto-merge kept it and the removal looks accidental. git diff of main against this head shows only that deletion in README. The runtime message for the same limitation is still in place, so merging as is would leave the docs silent on it. Could you restore the two lines after the rp flash deploy block?

Recurring schedules are not supported by `runpod.apps`. For periodic jobs, use
an external scheduler to invoke a deployed queue function with `.spawn()`.

## Contributing

Pull requests and issues are welcome — see the [contributing guide](CONTRIBUTING.md) to get started.
Expand Down
65 changes: 6 additions & 59 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ runpod = [
"serverless/binaries/gpu_test",
"serverless/binaries/README.md",
"py.typed",
"*.pyi",
]

[tool.setuptools_scm]
Expand All @@ -60,8 +61,8 @@ local_scheme = "no-local-version"


[project.scripts]
runpod = "runpod.rp_cli.main:run"
rp = "runpod.rp_cli.main:run"
runpod = "runpod.cli.main:run"
rp = "runpod.cli.main:run"


[dependency-groups]
Expand Down Expand Up @@ -106,6 +107,9 @@ select = ["E4", "E7", "E9", "F", "B", "I", "UP"]
# UP042 (str+Enum -> StrEnum) changes str()/format() output of public enums.
ignore = ["UP042"]

[tool.ruff.lint.isort]
combine-as-imports = true

[tool.mypy]
python_version = "3.11"
files = ["runpod"]
Expand All @@ -116,60 +120,3 @@ ignore_missing_imports = true
check_untyped_defs = false
warn_unused_configs = true
disable_error_code = ["annotation-unchecked"]

# Backlog: modules that do not pass yet. Remove an entry once the module is
# clean; new modules are checked from day one.
[[tool.mypy.overrides]]
module = [
"runpod._health.fitness",
"runpod._health.gpu",
"runpod.api.ctl_commands",
"runpod.api.rest",
"runpod.apps.api",
"runpod.apps.app",
"runpod.apps.auth",
"runpod.apps.build",
"runpod.apps.context",
"runpod.apps.deploy",
"runpod.apps.dev",
"runpod.apps.discovery",
"runpod.apps.gpu",
"runpod.apps.handles",
"runpod.apps.invoker",
"runpod.apps.spec",
"runpod.apps.targets",
"runpod.apps.tasks",
"runpod.apps.utils.http",
"runpod.apps.utils.network",
"runpod.apps.volume",
"runpod.endpoint.runner",
"runpod.network_volume_transfer",
"runpod.rp_cli.api",
"runpod.rp_cli.catalog",
"runpod.rp_cli.compute",
"runpod.rp_cli.console",
"runpod.rp_cli.endpoint",
"runpod.rp_cli.endpoint_config",
"runpod.rp_cli.main",
"runpod.rp_cli.pod",
"runpod.serverless",
"runpod.serverless.modules.rp_fastapi",
"runpod.serverless.modules.rp_http",
"runpod.serverless.modules.rp_job",
"runpod.serverless.modules.rp_local",
"runpod.serverless.modules.rp_ping",
"runpod.serverless.modules.rp_prestart",
"runpod.serverless.modules.rp_progress",
"runpod.serverless.modules.rp_scale",
"runpod.serverless.modules.rp_tips",
"runpod.serverless.modules.worker_state",
"runpod.serverless.utils.rp_cleanup",
"runpod.serverless.utils.rp_debugger",
"runpod.serverless.utils.rp_download",
"runpod.serverless.utils.rp_model_cache",
"runpod.serverless.utils.rp_ssrf",
"runpod.serverless.utils.rp_validator",
"runpod.serverless.utils.rp_volume_cache",
"runpod.serverless.worker",
]
ignore_errors = true
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ click >= 8.5.1
colorama >= 0.4.6, < 0.4.7
cryptography >= 50.0.2
fastapi[all] >= 0.162.5
opentelemetry-api < 1.46
Comment thread
KAJdev marked this conversation as resolved.
Resolved
packaging >= 26.3
paramiko >= 5.1.0
pathspec >= 1.1.1
Expand Down
173 changes: 7 additions & 166 deletions runpod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import importlib
import logging
import os
from typing import TYPE_CHECKING

# early serverless-worker startup gate (fitness/hardware checks). safe to
# call at import time: it no-ops outside eligible worker processes and
Expand Down Expand Up @@ -38,9 +37,9 @@
"update_endpoint_template": "runpod.api.ctl_commands",
"update_user_settings": "runpod.api.ctl_commands",
# config helpers
"check_credentials": "runpod.cli.groups.config.functions",
"get_credentials": "runpod.cli.groups.config.functions",
"set_credentials": "runpod.cli.groups.config.functions",
"check_credentials": "runpod.auth.credentials",
"get_credentials": "runpod.auth.credentials",
"set_credentials": "runpod.auth.credentials",
# endpoint clients
"AsyncioEndpoint": "runpod.endpoint",
"AsyncioJob": "runpod.endpoint",
Expand Down Expand Up @@ -75,153 +74,6 @@
"serverless": "runpod.serverless",
}

# type checkers cannot see through __getattr__; mirror the lazy table so
# consumers get real definitions (tests/test_init_typing.py keeps it in sync)
if TYPE_CHECKING:
from runpod import (
serverless as serverless,
)
from runpod._logger import (
RunPodLogger as RunPodLogger,
)
from runpod.api.ctl_commands import (
create_container_registry_auth as create_container_registry_auth,
)
from runpod.api.ctl_commands import (
create_endpoint as create_endpoint,
)
from runpod.api.ctl_commands import (
create_pod as create_pod,
)
from runpod.api.ctl_commands import (
create_template as create_template,
)
from runpod.api.ctl_commands import (
delete_container_registry_auth as delete_container_registry_auth,
)
from runpod.api.ctl_commands import (
get_endpoints as get_endpoints,
)
from runpod.api.ctl_commands import (
get_gpu as get_gpu,
)
from runpod.api.ctl_commands import (
get_gpus as get_gpus,
)
from runpod.api.ctl_commands import (
get_pod as get_pod,
)
from runpod.api.ctl_commands import (
get_pods as get_pods,
)
from runpod.api.ctl_commands import (
get_user as get_user,
)
from runpod.api.ctl_commands import (
resume_pod as resume_pod,
)
from runpod.api.ctl_commands import (
stop_pod as stop_pod,
)
from runpod.api.ctl_commands import (
terminate_pod as terminate_pod,
)
from runpod.api.ctl_commands import (
update_container_registry_auth as update_container_registry_auth,
)
from runpod.api.ctl_commands import (
update_endpoint_template as update_endpoint_template,
)
from runpod.api.ctl_commands import (
update_user_settings as update_user_settings,
)
from runpod.apps import (
Api as Api,
)
from runpod.apps import (
App as App,
)
from runpod.apps import (
DataCenter as DataCenter,
)
from runpod.apps import (
EndpointNotFound as EndpointNotFound,
)
from runpod.apps import (
GlobalVolume as GlobalVolume,
)
from runpod.apps import (
Job as Job,
)
from runpod.apps import (
Model as Model,
)
from runpod.apps import (
NetworkVolume as NetworkVolume,
)
from runpod.apps import (
Queue as Queue,
)
from runpod.apps import (
Secret as Secret,
)
from runpod.apps import (
Task as Task,
)
from runpod.apps import (
Volume as Volume,
)
from runpod.apps import (
is_local as is_local,
)
from runpod.apps import (
local_entrypoint as local_entrypoint,
)
from runpod.apps.gpu import (
CpuInstanceType as CpuInstanceType,
)
from runpod.apps.gpu import (
GpuGroup as GpuGroup,
)
from runpod.apps.gpu import (
GpuType as GpuType,
)
from runpod.apps.markers import (
delete as delete,
)
from runpod.apps.markers import (
get as get,
)
from runpod.apps.markers import (
init as init,
)
from runpod.apps.markers import (
patch as patch,
)
from runpod.apps.markers import (
post as post,
)
from runpod.apps.markers import (
put as put,
)
from runpod.cli.groups.config.functions import (
check_credentials as check_credentials,
)
from runpod.cli.groups.config.functions import (
get_credentials as get_credentials,
)
from runpod.cli.groups.config.functions import (
set_credentials as set_credentials,
)
from runpod.endpoint import (
AsyncioEndpoint as AsyncioEndpoint,
)
from runpod.endpoint import (
AsyncioJob as AsyncioJob,
)
from runpod.endpoint import (
Endpoint as Endpoint,
)

# lazy names resolve through __getattr__, so __all__ derives from the
# lazy table plus the eagerly-defined module attributes
Expand All @@ -248,22 +100,10 @@ def _selected_profile() -> str:


def _load_api_key():
"""resolve the api key from the environment, then stored credentials.
"""resolve the api key from the environment or selected profile."""
from .auth import load_api_key

the credential lookup is deferred (and tolerant of a missing cli
dependency closure) so a bare `import runpod` never drags in the
config/cli modules; the deployed worker gets its key from the env.
"""
key = os.environ.get("RUNPOD_API_KEY")
if key:
return key
try:
creds = importlib.import_module(
"runpod.cli.groups.config.functions"
).get_credentials(profile)
except Exception: # noqa: BLE001 - no stored key is a valid state
return None
return creds.get("api_key") if creds else None
return load_api_key(profile)


def __getattr__(name):
Expand Down Expand Up @@ -291,6 +131,7 @@ def __getattr__(name):
endpoint_url_base = os.environ.get(
"RUNPOD_ENDPOINT_BASE_URL", "https://api.runpod.ai/v2"
) # pylint: disable=invalid-name
_initial_endpoint_url_base = endpoint_url_base


# --------------------------- Force Logging Levels --------------------------- #
Expand Down
Loading
Loading