Skip to content

Commit

Permalink
use os.path.join
Browse files Browse the repository at this point in the history
Signed-off-by: Max de Bayser <[email protected]>
  • Loading branch information
maxdebayser committed Sep 18, 2024
1 parent 04a1c50 commit 2487c13
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions fmperf/loadgen/generate-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def generate_tgis_request(config, url):
# overwrite
overwrite = os.getenv("OVERWRITE", "false").lower() != "false"

if os.path.isfile("%s%s" % (REQUESTS_DIR, 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 @@ -288,5 +288,5 @@ def find_class(self, module, name):

if len(cases) > 0:
print(">> Writing %d requests to %s" % (len(cases), filename))
with open("%s%s" % (REQUESTS_DIR, filename), "w") as f:
with open(os.path.join(REQUESTS_DIR, filename), "w") as f:
json.dump(cases, f)
2 changes: 1 addition & 1 deletion fmperf/loadgen/generate-text-from-quac.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def main():
quac = QuACScenario()
prompts = quac.get_prompts()

filename = "{REQUESTS_DIR}/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
4 changes: 2 additions & 2 deletions fmperf/loadgen/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def get_streaming_response_vllm(response):
# we have stopped
yield None, 0, time.time_ns(), False, StopIteration()

infile = "%s%s" % (REQUESTS_DIR, REQUESTS_FILENAME)
outfile = "%s%s" % (REQUESTS_DIR, 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
4 changes: 2 additions & 2 deletions fmperf/loadgen/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

run()

filename = "%srequests/result_sweep_u%d.json" % (REQUESTS_DIR, 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 @@ -23,7 +23,7 @@

parse_results(results, print_df=True)

outfile = f"{REQUESTS_DIR}{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)
4 changes: 1 addition & 3 deletions fmperf/utils/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

REQUESTS_DIR = (lambda s: s + "/" if len(s) > 1 and not s.endswith("/") else s)(
os.environ.get("REQUESTS_DIR", "")
)
REQUESTS_DIR = os.environ.get("REQUESTS_DIR", "")
REQUESTS_FILENAME = os.environ["REQUESTS_FILENAME"]
RESULTS_ALL_FILENAME = os.environ["RESULTS_ALL_FILENAME"]

0 comments on commit 2487c13

Please sign in to comment.