-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rewrote js loader to uniform with the others
- Loading branch information
1 parent
efa8aaf
commit 9291287
Showing
4 changed files
with
33 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
FROM node:23-slim | ||
FROM python:3.12-slim | ||
|
||
RUN apt-get update && apt-get install -y nodejs npm | ||
|
||
WORKDIR /app | ||
|
||
COPY main.js . | ||
COPY dyana.py . | ||
COPY main.py . | ||
|
||
ARG EXTRA_REQUIREMENTS | ||
RUN if [ -n "$EXTRA_REQUIREMENTS" ]; then npm install $EXTRA_REQUIREMENTS; fi | ||
|
||
ENTRYPOINT ["node", "main.js"] | ||
ENTRYPOINT ["python3", "-W", "ignore", "main.py"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import argparse | ||
import json | ||
import os | ||
import subprocess | ||
|
||
from dyana import Profiler # type: ignore[attr-defined] | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Run an Javascript file") | ||
parser.add_argument("--script", help="Path to Javascript file", required=True) | ||
args = parser.parse_args() | ||
profiler: Profiler = Profiler() | ||
|
||
if not os.path.exists(args.script): | ||
profiler.track_error("js", "Javascript file not found") | ||
else: | ||
try: | ||
result = subprocess.run(["node", args.script], capture_output=True, text=True) | ||
|
||
profiler.track_memory("after_execution") | ||
profiler.track("exit_code", result.returncode) | ||
profiler.track("stdout", result.stdout) | ||
profiler.track("stderr", result.stderr) | ||
except Exception as e: | ||
profiler.track_error("js", str(e)) | ||
|
||
print(json.dumps(profiler.as_dict())) |