Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the base directory for requests configurable #32

Merged
merged 6 commits into from
Sep 20, 2024
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ FRAC_GREEDY=1.0
# number of input requests to generate (virtual users will sample from these)
SAMPLE_SIZE=1

# Default requests directory
REQUESTS_DIR=/requests

# requests file
REQUESTS_FILENAME=sample_requests.json

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ WORKDIR /home/fmperf
# Set permissions for openshift
RUN chmod -R g+rwx /home/fmperf

ENV REQUESTS_DIR=/requests
# Sanity check: We can import the installed wheel
RUN python -c "import ${SOURCE_DIR}"
5 changes: 3 additions & 2 deletions fmperf/loadgen/generate-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import fmperf.data
import traceback
from transformers import AutoTokenizer
from fmperf.utils.constants import REQUESTS_DIR

# read in seed text
seed_text_file = impresources.files(fmperf.data) / "ai.txt"
Expand Down Expand Up @@ -206,7 +207,7 @@ def generate_tgis_request(config, url):
# overwrite
overwrite = os.getenv("OVERWRITE", "false").lower() != "false"

if os.path.isfile("/requests/%s" % (filename)) and not overwrite:
if os.path.isfile(os.path.join(REQUESTS_DIR, filename)) and not overwrite:
print("File %s already exists; skipping workload generation" % (filename))
sys.exit()

Expand Down Expand Up @@ -287,5 +288,5 @@ def find_class(self, module, name):

if len(cases) > 0:
print(">> Writing %d requests to %s" % (len(cases), filename))
with open("/requests/%s" % (filename), "w") as f:
with open(os.path.join(REQUESTS_DIR, filename), "w") as f:
json.dump(cases, f)
3 changes: 2 additions & 1 deletion fmperf/loadgen/generate-text-from-quac.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import random
import requests
from typing import List, Tuple
from fmperf.utils.constants import REQUESTS_DIR


class QuACScenario:
Expand Down Expand Up @@ -167,7 +168,7 @@ def main():
quac = QuACScenario()
prompts = quac.get_prompts()

filename = "/requests/sample_texts.json"
filename = os.path.join(REQUESTS_DIR, "sample_texts.json")
print(">> Writing to %s" % (filename))
with open(filename, "w") as f:
json.dump(prompts, f, ensure_ascii=False)
Expand Down
5 changes: 3 additions & 2 deletions fmperf/loadgen/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from fmperf.utils import parse_results
from datetime import datetime
from .collect_energy import collect_metrics, summarize_energy
from fmperf.utils.constants import REQUESTS_DIR, REQUESTS_FILENAME, RESULTS_ALL_FILENAME


def run():
Expand Down Expand Up @@ -71,8 +72,8 @@ def get_streaming_response_vllm(response):
# we have stopped
yield None, 0, time.time_ns(), False, StopIteration()

infile = "/requests/%s" % (os.environ["REQUESTS_FILENAME"])
outfile = "/requests/%s" % (os.environ["RESULTS_FILENAME"])
infile = os.path.join(REQUESTS_DIR, REQUESTS_FILENAME)
outfile = os.path.join(REQUESTS_DIR, RESULTS_FILENAME)
target = os.environ["TARGET"]
api_url = os.environ["URL"]
num_users = int(os.environ["NUM_USERS"])
Expand Down
5 changes: 3 additions & 2 deletions fmperf/loadgen/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
from .run import run
from fmperf.utils import parse_results
from fmperf.utils.constants import REQUESTS_DIR, RESULTS_ALL_FILENAME

users = [int(u) for u in os.environ["SWEEP_USERS"].split(",")]

Expand All @@ -13,7 +14,7 @@

run()

filename = "/requests/result_sweep_u%d.json" % (u)
filename = os.path.join(REQUESTS_DIR, "requests/result_sweep_u%d.json" % (u))

with open(filename, "rb") as f:
tmp = json.load(f)
Expand All @@ -22,7 +23,7 @@

parse_results(results, print_df=True)

outfile = f"/requests/{os.environ['RESULTS_ALL_FILENAME']}"
outfile = os.path.point(REQUESTS_DIR, RESULTS_ALL_FILENAME)
print(f">> writing all results to file: {outfile}")
with open(outfile, "w") as f:
json.dump(results, f)
5 changes: 5 additions & 0 deletions fmperf/utils/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os

REQUESTS_DIR = os.environ.get("REQUESTS_DIR", ".")
REQUESTS_FILENAME = os.environ["REQUESTS_FILENAME"]
RESULTS_ALL_FILENAME = os.environ["RESULTS_ALL_FILENAME"]
Loading