Skip to content

Commit

Permalink
check for running kube before launch (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmagoon authored Nov 27, 2024
1 parent e964d41 commit 8dbbea6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies = [
"setuptools==69.0.2",
"requests==2.31.0",
"boto3==1.34.79",
"colorama==0.4.6",
"mixpanel==4.10.1",
"langchain==0.1.15",
"langchain-openai==0.1.2",
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def get_package_version():
version = package_data.get('version')

if version:

init_file_path = "zetaforge/__init__.py"
init_content = f"__version__ = '{version}'\nfrom .block_maker.zetahelper import block_maker\nfrom .Zetaforge import Zetaforge\n"

if not os.path.exists(init_file_path) or not open(init_file_path).read().startswith("__version__"):
with open(init_file_path, "w") as fp:
fp.write(init_content)

return version
else:
raise ValueError("Version not found in package.json")
Expand All @@ -31,9 +31,10 @@ def get_package_version():
except json.JSONDecodeError:
raise ValueError("Invalid JSON format in package.json")

package_version = get_package_version()

setup(
version = get_package_version(),
version = package_version,
entry_points={
'console_scripts': [
'zetaforge = zetaforge.forge_cli:main'
Expand Down
10 changes: 6 additions & 4 deletions zetaforge/forge_cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from zetaforge.logger import CliLogger
from .forge_runner import run_forge, teardown, purge, setup, uninstall
from .forge_runner import run_forge, teardown, purge, setup, uninstall, check_running_kube
from .install_forge_dependencies import check_version_exists, install_new_version, get_launch_paths, remove_running_services
import argparse, os, json
from pathlib import Path
from .__init__ import __version__
from colorama import init, Fore, Style
from .mixpanel_client import mixpanel_client

EXECUTABLES_PATH = os.path.join(Path(__file__).parent, 'executables')
Expand All @@ -26,8 +25,6 @@ def main():
parser.add_argument("--is_dev" , "-dev", action="store_true", help="If passed, the mixpanel events will have a field, is_dev that is set to be True")
args = parser.parse_args()

init() # Initialize colorama

server_versions = [__version__]
client_versions =[__version__]
client_path, server_path = get_launch_paths(server_versions[-1], client_versions[-1])
Expand All @@ -50,6 +47,11 @@ def main():
config = load_config(config_file)

if config is not None and success:
context = config["KubeContext"]
running_kube = check_running_kube(context)
if not running_kube:
raise Exception("Kubernetes is not running, please start kubernetes and ensure that you are able to connect to the kube context.")

run_forge(server_version=server_versions[-1], client_version=client_versions[-1], server_path=args.s2_path, client_path=args.app_path, is_dev=args.is_dev)
else:
raise Exception("Config failed to load, please re-run `zetaforge setup`.")
Expand Down
6 changes: 0 additions & 6 deletions zetaforge/forge_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from .check_forge_dependencies import check_minikube, check_running_kube, check_kube_pod, check_kubectl
from .install_forge_dependencies import *
from pathlib import Path
from colorama import init, Fore
from datetime import datetime
import socket
import json
Expand Down Expand Up @@ -156,9 +155,6 @@ def setup(server_version, client_version, driver, build_flag = True, install_fla
raise Exception("Exception while setting the context")

mixpanel_client.track_event("Setup - Context changed")
running_kube = check_running_kube(context)
if not running_kube:
raise Exception("Kubernetes is not running, please start kubernetes and ensure that you are able to connect to the kube context.")

config_path = write_json(server_version, client_version, context, driver, is_dev, s2_path=server_path)

Expand Down Expand Up @@ -189,8 +185,6 @@ def run_forge(server_version=None, client_version=None, server_path=None, client
time_start = datetime.now()
mixpanel_client.track_event('Launch Initiated')
change_env_config(server_version, client_version, is_dev)
#init is called for collarama library, better logging.
init()

if server_path is None:
_, server_path = get_launch_paths(server_version, client_version)
Expand Down

0 comments on commit 8dbbea6

Please sign in to comment.