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

Script to create python enviroment and run DashAI #202

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
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
55 changes: 55 additions & 0 deletions run-dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import os
import pathlib
import subprocess
from subprocess import Popen


def init_dev():
"""
Main function to start the dashai application.

The function only works if the PATH environment variable has python as
the python 3.8 executable.
"""
venv_name = "env"
local_path = pathlib.Path("~/.DashAI").expanduser()
venv_path = os.path.join(local_path, venv_name)

if not os.path.exists(local_path):
os.mkdir(local_path)

if not os.path.exists(venv_path):
subprocess.run(["python", "-m", "venv", venv_path])

scripts_path = os.path.join(venv_path, "Scripts") # ~/.DashAI/venv/Scripts
pip_path = os.path.join(scripts_path, "pip")

subprocess.run([pip_path, "install", "-r", "requirements.txt"])
subprocess.run([pip_path, "install", "-r", "requirements-dev.txt"])

# Command to open terminal and run the commands
full_command = "start cmd /c "

actual_path = pathlib.Path(__file__).parent.absolute()
front_path = pathlib.Path(actual_path, "DashAI/front")

# Command to start the front
yarn_command = full_command + f"yarn --cwd {front_path} start"

# Command to start the backend
python_command = (
full_command + f"{os.path.join(scripts_path, 'python.exe')} -m DashAI"
)

try:
# Execute the command to start the front
Popen(yarn_command, shell=True)

# Execute the command to start the backend
Popen(python_command, shell=True)

except KeyboardInterrupt:
pass


init_dev()
Loading