Skip to content

Commit 8d61293

Browse files
committed
use new config in main.py
1 parent e64b547 commit 8d61293

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/warnet/main.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import sys
77
from dataclasses import dataclass
88
from enum import Enum, auto
9-
from importlib.resources import files
109
from pathlib import Path
1110
from typing import Callable
1211

@@ -15,6 +14,14 @@
1514
import yaml
1615
from inquirer.themes import GreenPassion
1716

17+
from warnet.constants import (
18+
DEFAULT_TAG,
19+
DEFAULTS_FILE,
20+
NETWORK_DIR,
21+
NETWORK_FILE,
22+
SRC_DIR,
23+
SUPPORTED_TAGS,
24+
)
1825
from warnet.k8s import get_default_namespace
1926
from warnet.process import run_command, stream_command
2027

@@ -26,9 +33,8 @@
2633
from .image import image
2734
from .network import copy_network_defaults, copy_scenario_defaults
2835
from .status import status as status_command
29-
from .util import DEFAULT_TAG, SUPPORTED_TAGS
3036

31-
QUICK_START_PATH = files("resources.scripts").joinpath("quick_start.sh")
37+
QUICK_START_PATH = SRC_DIR.joinpath("resources", "scripts", "quick_start.sh")
3238

3339

3440
@click.group()
@@ -592,10 +598,6 @@ def logs(pod_name: str, follow: bool):
592598
pass # cancelled by user
593599

594600

595-
if __name__ == "__main__":
596-
cli()
597-
598-
599601
def custom_graph(
600602
num_nodes: int,
601603
num_connections: int,
@@ -639,17 +641,19 @@ def custom_graph(
639641
"configQueryInterval": fork_obs_query_interval,
640642
}
641643

642-
with open(os.path.join(datadir, "network.yaml"), "w") as f:
644+
with open(os.path.join(datadir, NETWORK_FILE), "w") as f:
643645
yaml.dump(network_yaml_data, f, default_flow_style=False)
644646

645647
# Generate node-defaults.yaml
646-
default_yaml_path = files("resources.networks").joinpath("node-defaults.yaml")
648+
default_yaml_path = NETWORK_DIR.joinpath(DEFAULTS_FILE)
647649
with open(str(default_yaml_path)) as f:
648650
defaults_yaml_content = f.read()
649651

650-
with open(os.path.join(datadir, "node-defaults.yaml"), "w") as f:
652+
with open(os.path.join(datadir, DEFAULTS_FILE), "w") as f:
651653
f.write(defaults_yaml_content)
652654

653-
click.echo(
654-
f"Project '{datadir}' has been created with 'network.yaml' and 'node-defaults.yaml'."
655-
)
655+
click.echo(f"Project '{datadir}' has been created with '{NETWORK_FILE}' and '{DEFAULTS_FILE}'.")
656+
657+
658+
if __name__ == "__main__":
659+
cli()

0 commit comments

Comments
 (0)