Skip to content

Commit

Permalink
Merge branch 'update-default-logger' into log-level-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewitt1 committed Aug 22, 2024
2 parents 0b8428a + 8325af7 commit 9b372e0
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 154 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/cluster_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: cluster-tests

on: workflow_dispatch

env:
RH_LOG_LEVEL: "INFO"

jobs:
cluster-tests:
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/copy_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
branches:
- '*'

env:
RH_LOG_LEVEL: "INFO"

jobs:
generate-docs:
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/generate_docs_for_tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ on:
required: false # Allow empty for cases where the release event provides the tag
default: ''

env:
RH_LOG_LEVEL: "INFO"

jobs:
build-docs-for-tag:
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/local_den_unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Local Den Unit Tests

on: workflow_dispatch

env:
RH_LOG_LEVEL: "INFO"

jobs:
local-den-tests:
runs-on: ubuntu-latest
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/local_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:

env:
API_SERVER_URL: https://api.run.house
RH_LOG_LEVEL: "INFO"

jobs:
# TODO: THESE ARE ONLY SEPARATE JOBS BECAUSE THERE ARE
Expand Down Expand Up @@ -43,7 +42,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local tests/test_servers/
env:
Expand Down Expand Up @@ -82,7 +80,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "not servertest and not secrettest and not moduletest and not functiontest and not envtest and not clustertest"
env:
Expand Down Expand Up @@ -123,7 +120,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "secrettest"
env:
Expand All @@ -149,7 +145,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "moduletest"
env:
Expand All @@ -175,7 +170,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "functiontest"
env:
Expand All @@ -201,7 +195,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "envtest"
env:
Expand All @@ -227,7 +220,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "clustertest"
env:
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/local_tests_den_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:

env:
API_SERVER_URL: https://api-dev.run.house
RH_LOG_LEVEL: "INFO"

jobs:
# TODO: THESE ARE ONLY SEPARATE JOBS BECAUSE THERE ARE
Expand Down Expand Up @@ -41,7 +40,7 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}


- name: pytest -v --level local tests/test_servers/
env:
Expand Down Expand Up @@ -80,7 +79,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "not servertest and not secrettest and not moduletest and not functiontest and not envtest"
env:
Expand Down Expand Up @@ -121,7 +119,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "secrettest"
env:
Expand All @@ -147,7 +144,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "moduletest"
env:
Expand All @@ -173,7 +169,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "functiontest"
env:
Expand All @@ -199,7 +194,6 @@ jobs:
username: ${{ secrets.CI_ACCOUNT_USERNAME }}
token: ${{ secrets.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ env.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}

- name: pytest -v --level local -k "envtest"
env:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/nightly_release_testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
# Run every night at 2 AM UTC
- cron: '0 2 * * *'

env:
RH_LOG_LEVEL: "INFO"

jobs:
not-cluster-tests:
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/sagemaker_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: sagemaker-tests

on: workflow_dispatch

env:
RH_LOG_LEVEL: "INFO"

jobs:
sagemaker-tests:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/setup_release_testing/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ runs:
username: ${{ inputs.CI_ACCOUNT_USERNAME }}
token: ${{ inputs.CI_ACCOUNT_TOKEN }}
api_server_url: ${{ inputs.API_SERVER_URL }}
rh_log_level: ${{ env.RH_LOG_LEVEL }}
5 changes: 0 additions & 5 deletions .github/workflows/setup_rh_config/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ inputs:
description: 'The den api server to send the requests to'
required: true

rh_log_level:
description: 'Cluster log level'
required: true

runs:
using: composite
steps:
Expand All @@ -31,4 +27,3 @@ runs:
echo "token: ${{ inputs.token }}" >> ~/.rh/config.yaml
echo "username: ${{ inputs.username }}" >> ~/.rh/config.yaml
echo "api_server_url: ${{ inputs.api_server_url }}" >> ~/.rh/config.yaml
echo "rh_log_level: ${{ inputs.rh_log_level }}" >> ~/.rh/config.yaml
3 changes: 0 additions & 3 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
branches: [ main ]
pull_request:

env:
RH_LOG_LEVEL: "INFO"

jobs:
all-tests-logged-out-level-unit:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions docs/debugging-logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Alternatively, to see logs on your local machine while running a remote function
Log Levels
----------
You can set the log level to control the verbosity of the Runhouse logs. You can adjust the log level by
setting the environment variable ``RH_LOG_LEVEL`` to your desired level, or by setting the `rh_log_level` field
in your local `~/.rh/config.yaml`.
setting the environment variable ``RH_LOG_LEVEL`` to your desired level.

Debugging
~~~~~~~~~
Expand Down
19 changes: 10 additions & 9 deletions examples/llama3-8b-ec2/llama3_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
import torch

# Next, we define a class that will hold the model and allow us to send prompts to it.
# You'll notice this class inherits from `rh.Module`.
# We'll later wrap this with `rh.module`.
# This is a Runhouse class that allows you to
# run code in your class on a remote machine.
#
# Learn more in the [Runhouse docs on functions and modules](/docs/tutorials/api-modules).
class HFChatModel(rh.Module):
class HFChatModel:
def __init__(self, model_id="meta-llama/Meta-Llama-3-8B-Instruct", **model_kwargs):
super().__init__()
self.model_id, self.model_kwargs = model_id, model_kwargs
Expand Down Expand Up @@ -129,15 +129,16 @@ def predict(self, prompt_text, **inf_kwargs):
)

# Finally, we define our module and run it on the remote cluster. We construct it normally and then call
# `get_or_to` to run it on the remote cluster. Using `get_or_to` allows us to load the exiting Module
# by the name `llama3-8b-model` if it was already put on the cluster. If we want to update the module each
# time we run this script, we can use `to` instead of `get_or_to`.
# `to` to run it on the remote cluster. Alternatively, we could first check for an existing instance on the cluster
# by calling `cluster.get(name="llama3-8b-model")`. This would return the remote model after an initial run.
# If we want to update the module each time we run this script, we prefer to use `to`.
#
# Note that we also pass the `env` object to the `get_or_to` method, which will ensure that the environment is
# Note that we also pass the `env` object to the `to` method, which will ensure that the environment is
# set up on the remote machine before the module is run.
remote_hf_chat_model = HFChatModel(
torch_dtype=torch.bfloat16,
).get_or_to(gpu, env=env, name="llama3-8b-model")
RemoteChatModel = rh.module(HFChatModel).to(gpu, env=env, name="HFChatModel")
remote_hf_chat_model = RemoteChatModel(
torch_dtype=torch.bfloat16, name="llama3-8b-model"
)

# ## Calling our remote function
#
Expand Down
17 changes: 8 additions & 9 deletions examples/llama3-fine-tuning-lora/llama3_fine_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
import runhouse as rh

# Next, we define a class that will hold the various methods needed to fine-tune the model.
# You'll notice this class inherits from `rh.Module`. This is a Runhouse class that allows you to
# We'll later wrap this with `rh.module`. This is a Runhouse class that allows you to
# run code in your class on a remote machine.
#
# Learn more in the [Runhouse docs on functions and modules](/docs/tutorials/api-modules).

DEFAULT_MAX_LENGTH = 200


class FineTuner(rh.Module):
class FineTuner:
def __init__(
self,
dataset_name="Shekswess/medical_llama3_instruct_dataset_short",
Expand Down Expand Up @@ -268,15 +268,14 @@ def generate(self, query: str, max_length: int = DEFAULT_MAX_LENGTH):
)

# Finally, we define our module and run it on the remote cluster. We construct it normally and then call
# `get_or_to` to run it on the remote cluster. Using `get_or_to` allows us to load the exiting Module
# by the name `llama3-medical-model` if it was already put on the cluster. If we want to update the Module each
# time we run this script, we can use `to` instead of `get_or_to`.
# `to` to run it on the remote cluster. Alternatively, we could first check for an existing instance on the cluster
# by calling `cluster.get(name="llama3-medical-model")`. This would return the remote model after an initial run.
# If we want to update the module each time we run this script, we prefer to use `to`.
#
# Note that we also pass the `env` object to the `get_or_to` method, which will ensure that the environment is
# Note that we also pass the `env` object to the `to` method, which will ensure that the environment is
# set up on the remote machine before the module is run.
fine_tuner_remote = FineTuner().get_or_to(
cluster, env=env, name="llama3-medical-model"
)
RemoteFineTuner = rh.module(FineTuner).to(cluster, env=env, name="FineTuner")
fine_tuner_remote = RemoteFineTuner(name="llama3-medical-model")

# ## Fine-tune the model on the cluster
#
Expand Down
1 change: 0 additions & 1 deletion runhouse/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def get_logger(name: str = __name__):

level = os.getenv("RH_LOG_LEVEL")
if level:
# Set the logging level
logger.setLevel(level.upper())

# Check if the logger already has handlers, add a StreamHandler if not
Expand Down
12 changes: 0 additions & 12 deletions runhouse/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ def _start_server(
default_env_name=None,
conda_env=None,
from_python=None,
log_level=None,
):
############################################
# Build CLI commands to start the server
Expand Down Expand Up @@ -627,7 +626,6 @@ def _start_server(
flags.append(conda_env_flag)

flags.append(" --from-python" if from_python else "")
flags.append(f" --log-level {log_level}" if log_level else "")

# Check if screen or nohup are available
screen = screen and _check_if_command_exists("screen")
Expand Down Expand Up @@ -745,10 +743,6 @@ def start(
conda_env: str = typer.Option(
None, help="Name of conda env corresponding to default env if it is a CondaEnv."
),
log_level: Optional[str] = typer.Option(
default=None,
help="Log level for the server",
),
):
"""Start the HTTP or HTTPS server on the cluster."""
_start_server(
Expand All @@ -766,7 +760,6 @@ def start(
certs_address=certs_address,
default_env_name=default_env_name,
conda_env=conda_env,
log_level=log_level,
)


Expand Down Expand Up @@ -833,10 +826,6 @@ def restart(
False,
help="Whether HTTP server started from inside a Python call rather than CLI.",
),
log_level: Optional[str] = typer.Option(
default=None,
help="Log level for the server",
),
):
"""Restart the HTTP server on the cluster."""
if name:
Expand Down Expand Up @@ -864,7 +853,6 @@ def restart(
default_env_name=default_env_name,
conda_env=conda_env,
from_python=from_python,
log_level=log_level,
)


Expand Down
1 change: 0 additions & 1 deletion runhouse/resources/hardware/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,6 @@ def restart_server(
+ (f" --domain {domain}" if domain else "")
+ f" --port {self.server_port}"
+ f" --api-server-url {rns_client.api_server_url}"
+ f" --log-level {rns_client.log_level}"
+ f" --default-env-name {self.default_env.name}"
+ (
f" --conda-env {self.default_env.env_name}"
Expand Down
Loading

0 comments on commit 9b372e0

Please sign in to comment.