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

Eng 1237 update install script to update UI #90

Merged
merged 3 commits into from
Jun 13, 2022
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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### SRC ###
# Ignore the build directory, which has compile Golang executables.
# Ignore the build directory, which has compile Golang executables and Python packages.
src/build/
src/python/build/

# Ignore any IDE configuration files
*.idea/
Expand Down
55 changes: 43 additions & 12 deletions scripts/install_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
The sdk will also be updated with any local changes.
"""

import argparse
import os
import shutil
import subprocess
import sys

base_directory = os.path.join(os.environ["HOME"], ".aqueduct")
server_directory = os.path.join(os.environ["HOME"], ".aqueduct", "server")
from os import listdir
from os.path import isfile, join, isdir

base_directory = join(os.environ["HOME"], ".aqueduct")
server_directory = join(os.environ["HOME"], ".aqueduct", "server")
ui_directory = join(os.environ["HOME"], ".aqueduct", "ui")


def execute_command(args, cwd=None):
Expand All @@ -26,28 +32,53 @@ def execute_command(args, cwd=None):


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--update-ui', dest="update_ui", default=False, action='store_true',
help="Whether to build and replace UI files.")
args = parser.parse_args()
print("Current directory should be the root directory of the aqueduct repo.")
cwd = os.getcwd()
if not cwd.endswith("aqueduct"):
print("Your working directory is %s" % cwd)
exit(1)

if not os.path.isdir(server_directory):
if not isdir(server_directory):
print("~/.aqueduct/server must exist.")
exit(1)

# Build the local backend binaries.
execute_command(["make", "server"], cwd=os.path.join(cwd, "src"))
execute_command(["cp", "./src/build/server", os.path.join(server_directory, "bin", "server")])
execute_command(["make", "executor"], cwd=os.path.join(cwd, "src"))
execute_command(["cp", "./src/build/executor", os.path.join(server_directory, "bin", "executor")])
# Build and replace backend binaries.
execute_command(["make", "server"], cwd=join(cwd, "src"))
execute_command(["make", "executor"], cwd=join(cwd, "src"))
if isfile(join(server_directory, "bin/server")):
execute_command(["rm", join(server_directory, "bin/server")])
if isfile(join(server_directory, "bin/executor")):
execute_command(["rm", join(server_directory, "bin/executor")])

execute_command(["cp", "./src/build/server", join(server_directory, "bin/server")])
execute_command(["cp", "./src/build/executor", join(server_directory, "bin/executor")])

# Build and replace UI files.
if args.update_ui:
execute_command(["npm", "install"], cwd=join(cwd, "src/ui/common"))
execute_command(["npm", "run", "build"], cwd=join(cwd, "src/ui/common"))
execute_command(["sudo", "npm", "link"], cwd=join(cwd, "src/ui/common"))
execute_command(["npm", "install"], cwd=join(cwd, "src/ui/app"))
execute_command(["npm", "link", "@aqueducthq/common"], cwd=join(cwd, "src/ui/app"))
execute_command(["make", "dist"], cwd=join(cwd, "src/ui"))

files = [f for f in listdir(ui_directory) if isfile(join(ui_directory, f))]
for f in files:
if not f == "__version__":
execute_command(["rm", f], cwd=ui_directory)

shutil.copytree(join(cwd, "src/ui/app/dist"), ui_directory, dirs_exist_ok=True)

# Install the local SDK.
os.environ["PWD"] = os.path.join(os.environ["PWD"], "sdk")
execute_command(["pip", "install", "."], cwd=os.path.join(cwd, "sdk"))
os.environ["PWD"] = join(os.environ["PWD"], "sdk")
execute_command(["pip", "install", "."], cwd=join(cwd, "sdk"))

# Install the local python operators.
os.environ["PWD"] = os.path.join(os.environ["PWD"], "../src/python")
execute_command(["pip", "install", "."], cwd=os.path.join(cwd, "src", "python"))
os.environ["PWD"] = join(os.environ["PWD"], "../src/python")
execute_command(["pip", "install", "."], cwd=join(cwd, "src", "python"))

print("Successfully installed aqueduct from local repo!")