Skip to content
Merged
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
2 changes: 1 addition & 1 deletion examples/endpoints/asyncio_job_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import asyncio

import runpod
from runpod import http_client, AsyncioEndpoint, AsyncioJob
from runpod import AsyncioEndpoint, AsyncioJob, http_client

asyncio.set_event_loop_policy(
asyncio.WindowsSelectorEventLoopPolicy()
Expand Down
2 changes: 1 addition & 1 deletion examples/graphql_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""

import time
import runpod

import runpod

runpod.api_key = "YOUR_RUNPOD_API_KEY"

Expand Down
2 changes: 1 addition & 1 deletion runpod/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Allows runpod to be imported as a module. """

import os
import logging
import os

from . import serverless
from .api.ctl_commands import (
Expand Down
2 changes: 1 addition & 1 deletion runpod/api/mutations/pods.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# pylint: disable=too-many-arguments, too-many-locals, too-many-branches

from typing import Optional, List
from typing import List, Optional


def generate_pod_deployment_mutation(
Expand Down
7 changes: 3 additions & 4 deletions runpod/cli/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

import click

from .groups.project.commands import project_cli

from .groups.config.commands import config_wizard
from .groups.ssh.commands import ssh_cli
from .groups.pod.commands import pod_cli
from .groups.exec.commands import exec_cli
from .groups.pod.commands import pod_cli
from .groups.project.commands import project_cli
from .groups.ssh.commands import ssh_cli


@click.group()
Expand Down
3 changes: 2 additions & 1 deletion runpod/cli/groups/config/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""

import sys

import click

from .functions import set_credentials, check_credentials
from .functions import check_credentials, set_credentials


@click.command("config", help="Configures the RunPod CLI with the user's API key.")
Expand Down
1 change: 1 addition & 0 deletions runpod/cli/groups/exec/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Helper functions for the runpod cli group exec command"""

import os

import click

from runpod import get_pod
Expand Down
2 changes: 1 addition & 1 deletion runpod/cli/groups/pod/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import click
from prettytable import PrettyTable

from runpod import get_pods, create_pod
from runpod import create_pod, get_pods

from ...utils import ssh_cmd

Expand Down
4 changes: 3 additions & 1 deletion runpod/cli/groups/project/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import os
import sys

import click
from InquirerPy import prompt as cli_select

from runpod import get_user
from .functions import create_new_project, start_project, create_project_endpoint

from .functions import create_new_project, create_project_endpoint, start_project
from .helpers import validate_project_name


Expand Down
17 changes: 9 additions & 8 deletions runpod/cli/groups/project/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@
from datetime import datetime

import tomlkit
from tomlkit import document, comment, table, nl
from tomlkit import comment, document, nl, table

from runpod import (
__version__,
get_pod,
create_template,
create_endpoint,
create_template,
get_pod,
update_endpoint_template,
)
from runpod.cli import BASE_DOCKER_IMAGE, GPU_TYPES, ENV_VARS
from runpod.cli import BASE_DOCKER_IMAGE, ENV_VARS, GPU_TYPES
from runpod.cli.utils.ssh_cmd import SSHConnection

from ...utils.rp_sync import sync_directory
from .helpers import (
get_project_pod,
copy_template_files,
attempt_pod_launch,
load_project_config,
copy_template_files,
get_project_endpoint,
get_project_pod,
load_project_config,
)
from ...utils.rp_sync import sync_directory

STARTER_TEMPLATES = os.path.join(os.path.dirname(__file__), "starter_templates")

Expand Down
5 changes: 3 additions & 2 deletions runpod/cli/groups/project/helpers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Helper functions for project group commands."""

import re
import os
import re
import shutil

import click
import tomlkit

from runpod import get_pods, create_pod, get_endpoints
from runpod import create_pod
from runpod import error as rp_error
from runpod import get_endpoints, get_pods


def validate_project_name(name):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

# pylint: skip-file

import runpod
import inspect

from transformers import HfApi

import runpod

SELECTED_MODEL = "<<MODEL_NAME>>"


Expand Down
3 changes: 2 additions & 1 deletion runpod/cli/groups/ssh/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import click
from prettytable import PrettyTable
from .functions import get_user_pub_keys, generate_ssh_key_pair

from .functions import generate_ssh_key_pair, get_user_pub_keys


@click.group("ssh", help="Manage and configure SSH keys for secure access to pods.")
Expand Down
3 changes: 2 additions & 1 deletion runpod/cli/groups/ssh/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
RunPod | CLI | SSH | Functions
"""

import os
import base64
import hashlib
import os

import paramiko

from runpod.api.ctl_commands import get_user, update_user_settings
Expand Down
2 changes: 1 addition & 1 deletion runpod/cli/utils/rp_runpodignore.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Reads the .runpodignore file and returns a list of files to ignore. """

import os
import fnmatch
import os

EXCLUDE_PATTERNS = [
"__pycache__/",
Expand Down
5 changes: 3 additions & 2 deletions runpod/cli/utils/rp_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
Watches a directory for changes and syncs them to a remote directory.
"""

import time
import threading
import time

from watchdog.observers.polling import PollingObserver as Observer
from watchdog.events import FileSystemEventHandler
from watchdog.observers.polling import PollingObserver as Observer

from runpod.cli import STOP_EVENT

from .rp_runpodignore import get_ignore_list, should_ignore


Expand Down
2 changes: 2 additions & 0 deletions runpod/cli/utils/rp_userspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"""

import os

import paramiko

from runpod import SSH_KEY_PATH


Expand Down
8 changes: 5 additions & 3 deletions runpod/cli/utils/ssh_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
Connect and run commands over SSH.
"""

import sys
import signal
import threading
import subprocess
import sys
import threading

import colorama
import paramiko

from runpod.cli import STOP_EVENT

from .rp_info import get_pod_ssh_ip_port
from .rp_userspace import find_ssh_key_file
from .rp_runpodignore import get_ignore_list
from .rp_userspace import find_ssh_key_file

colorama.init(autoreset=True) # Initialize colorama

Expand Down
2 changes: 1 addition & 1 deletion runpod/endpoint/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" Allows endpoints to be imported as a module. """

from .runner import Endpoint, Job
from .asyncio.asyncio_runner import Endpoint as AsyncioEndpoint
from .asyncio.asyncio_runner import Job as AsyncioJob
from .runner import Endpoint, Job
12 changes: 6 additions & 6 deletions runpod/endpoint/asyncio/asyncio_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

# pylint: disable=too-few-public-methods,R0801

from typing import Any, Dict
import asyncio
from typing import Any, Dict

from runpod.http_client import ClientSession
from runpod.endpoint.helpers import FINAL_STATES, is_completed
from runpod.http_client import ClientSession


class Job:
"""Class representing a job for an asynchronous endpoint"""

def __init__(self, endpoint_id: str, job_id: str, session: ClientSession):
from runpod import (
from runpod import ( # pylint: disable=import-outside-toplevel,cyclic-import
api_key,
endpoint_url_base,
) # pylint: disable=import-outside-toplevel,cyclic-import
)

self.endpoint_id = endpoint_id
self.job_id = job_id
Expand Down Expand Up @@ -109,9 +109,9 @@ class Endpoint:

def __init__(self, endpoint_id: str, session: ClientSession):
from runpod import (
api_key,
api_key, # pylint: disable=import-outside-toplevel
endpoint_url_base,
) # pylint: disable=import-outside-toplevel
)

self.endpoint_id = endpoint_id
self.endpoint_url = f"{endpoint_url_base}/{self.endpoint_id}/run"
Expand Down
9 changes: 5 additions & 4 deletions runpod/endpoint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
RunPod | Python | Endpoint Runner
"""

from typing import Any, Optional, Dict
import time
from typing import Any, Dict, Optional

import requests
from requests.adapters import HTTPAdapter, Retry

from runpod.endpoint.helpers import (
API_KEY_NOT_SET_MSG,
FINAL_STATES,
UNAUTHORIZED_MSG,
API_KEY_NOT_SET_MSG,
is_completed,
)

Expand All @@ -28,10 +29,10 @@ def __init__(self):
Raises:
RuntimeError: If the API key has not been initialized.
"""
from runpod import (
from runpod import ( # pylint: disable=import-outside-toplevel, cyclic-import
api_key,
endpoint_url_base,
) # pylint: disable=import-outside-toplevel, cyclic-import
)

if api_key is None:
raise RuntimeError(API_KEY_NOT_SET_MSG)
Expand Down
13 changes: 4 additions & 9 deletions runpod/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
"""

import os

import requests
from aiohttp import (
ClientSession,
ClientTimeout,
TCPConnector,
)
from .tracer import (
create_aiohttp_tracer,
create_request_tracer,
)
from aiohttp import ClientSession, ClientTimeout, TCPConnector

from .cli.groups.config.functions import get_credentials
from .tracer import create_aiohttp_tracer, create_request_tracer
from .user_agent import USER_AGENT


Expand Down
10 changes: 5 additions & 5 deletions runpod/serverless/core.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
""" Core functionality for the runpod serverless worker. """

import asyncio
import ctypes
import inspect
import json
import os
import pathlib
import asyncio
from ctypes import CDLL, byref, c_char_p, c_int
from typing import Any, Callable, List, Dict, Optional
import typing
from ctypes import CDLL, byref, c_char_p, c_int
from typing import Any, Callable, Dict, List, Optional

from runpod.version import __version__ as runpod_version
from runpod.serverless.modules.rp_logger import RunPodLogger
from runpod.serverless.modules import rp_job
from runpod.serverless.modules.rp_logger import RunPodLogger
from runpod.version import __version__ as runpod_version

log = RunPodLogger()

Expand Down
15 changes: 7 additions & 8 deletions runpod/serverless/modules/rp_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
# pylint: disable=too-few-public-methods, line-too-long

import os
import uuid
import threading
import uuid
from dataclasses import dataclass
from typing import Union, Optional, Dict, Any
from typing import Any, Dict, Optional, Union

import uvicorn
import requests
from fastapi import FastAPI, APIRouter
import uvicorn
from fastapi import APIRouter, FastAPI
from fastapi.encoders import jsonable_encoder
from fastapi.responses import RedirectResponse

from ...http_client import SyncClientSession
from ...version import __version__ as runpod_version
from .rp_handler import is_generator
from .rp_job import run_job, run_job_generator
from .worker_state import Jobs
from .rp_ping import Heartbeat
from ...version import __version__ as runpod_version
from ...http_client import SyncClientSession

from .worker_state import Jobs

RUNPOD_ENDPOINT_ID = os.environ.get("RUNPOD_ENDPOINT_ID", None)

Expand Down
Loading