|
6 | 6 | import sys
|
7 | 7 | from dataclasses import dataclass
|
8 | 8 | from enum import Enum, auto
|
9 |
| -from importlib.resources import files |
10 | 9 | from pathlib import Path
|
11 | 10 | from typing import Callable
|
12 | 11 |
|
|
15 | 14 | import yaml
|
16 | 15 | from inquirer.themes import GreenPassion
|
17 | 16 |
|
| 17 | +from warnet.constants import ( |
| 18 | + DEFAULT_TAG, |
| 19 | + DEFAULTS_FILE, |
| 20 | + NETWORK_DIR, |
| 21 | + NETWORK_FILE, |
| 22 | + SRC_DIR, |
| 23 | + SUPPORTED_TAGS, |
| 24 | +) |
18 | 25 | from warnet.k8s import get_default_namespace
|
19 | 26 | from warnet.process import run_command, stream_command
|
20 | 27 |
|
|
26 | 33 | from .image import image
|
27 | 34 | from .network import copy_network_defaults, copy_scenario_defaults
|
28 | 35 | from .status import status as status_command
|
29 |
| -from .util import DEFAULT_TAG, SUPPORTED_TAGS |
30 | 36 |
|
31 |
| -QUICK_START_PATH = files("resources.scripts").joinpath("quick_start.sh") |
| 37 | +QUICK_START_PATH = SRC_DIR.joinpath("resources", "scripts", "quick_start.sh") |
32 | 38 |
|
33 | 39 |
|
34 | 40 | @click.group()
|
@@ -592,10 +598,6 @@ def logs(pod_name: str, follow: bool):
|
592 | 598 | pass # cancelled by user
|
593 | 599 |
|
594 | 600 |
|
595 |
| -if __name__ == "__main__": |
596 |
| - cli() |
597 |
| - |
598 |
| - |
599 | 601 | def custom_graph(
|
600 | 602 | num_nodes: int,
|
601 | 603 | num_connections: int,
|
@@ -639,17 +641,19 @@ def custom_graph(
|
639 | 641 | "configQueryInterval": fork_obs_query_interval,
|
640 | 642 | }
|
641 | 643 |
|
642 |
| - with open(os.path.join(datadir, "network.yaml"), "w") as f: |
| 644 | + with open(os.path.join(datadir, NETWORK_FILE), "w") as f: |
643 | 645 | yaml.dump(network_yaml_data, f, default_flow_style=False)
|
644 | 646 |
|
645 | 647 | # Generate node-defaults.yaml
|
646 |
| - default_yaml_path = files("resources.networks").joinpath("node-defaults.yaml") |
| 648 | + default_yaml_path = NETWORK_DIR.joinpath(DEFAULTS_FILE) |
647 | 649 | with open(str(default_yaml_path)) as f:
|
648 | 650 | defaults_yaml_content = f.read()
|
649 | 651 |
|
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: |
651 | 653 | f.write(defaults_yaml_content)
|
652 | 654 |
|
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