fix: cli config should not require PythonGateway server started (#154)
cli `configh` subcommand should not require or check wether pythongateway server launched or not, related #153 and https://github.com/apache/dolphinscheduler-sdk-python/issues/152#issuecomment-2314794223
diff --git a/src/pydolphinscheduler/cli/commands.py b/src/pydolphinscheduler/cli/commands.py
index 6a09326..457a350 100644
--- a/src/pydolphinscheduler/cli/commands.py
+++ b/src/pydolphinscheduler/cli/commands.py
@@ -26,7 +26,6 @@
init_config_file,
set_single_config,
)
-from pydolphinscheduler.core.yaml_workflow import create_workflow
version_option_val = ["major", "minor", "micro"]
@@ -103,4 +102,6 @@
)
def yaml(yaml_file) -> None:
"""Create workflow using YAML file."""
+ from pydolphinscheduler.core.yaml_workflow import create_workflow
+
create_workflow(yaml_file)
diff --git a/src/pydolphinscheduler/configuration.py b/src/pydolphinscheduler/configuration.py
index 00438db..2a73446 100644
--- a/src/pydolphinscheduler/configuration.py
+++ b/src/pydolphinscheduler/configuration.py
@@ -28,6 +28,7 @@
BUILD_IN_CONFIG_PATH = Path(__file__).resolve().parent.joinpath("default_config.yaml")
logger = logging.getLogger(__name__)
+logging.basicConfig()
def config_path() -> Path:
@@ -50,13 +51,14 @@
def init_config_file() -> None:
"""Initialize configuration file by default configs."""
- if config_path().exists():
+ path: Path = config_path()
+ if path.exists():
raise PyDSConfException(
"Initialize configuration false to avoid overwrite configure by accident, file already exists "
"in %s, if you wan to overwrite the exists configure please remove the exists file manually.",
- str(config_path()),
+ str(path),
)
- file.write(content=str(get_configs()), to_path=str(config_path()))
+ file.write(content=str(get_configs()), to_path=str(path))
def get_single_config(key: str) -> Any:
@@ -131,13 +133,12 @@
"Auth token is None, highly recommend add a token in production, "
"especially you deploy in public network."
)
- with open(BUILD_IN_CONFIG_PATH) as f:
- config = YamlParser(f.read())
- if config.get("java_gateway.auth_token") == auth_token:
- logger.warning(
- "Auth token is default token, highly recommend add a token in production, "
- "especially you deploy in public network."
- )
+ config = get_configs()
+ if config.get("java_gateway.auth_token") == auth_token:
+ logger.warning(
+ "Auth token is default token, highly recommend add a token in production, "
+ "especially you deploy in public network."
+ )
def get_int(val: Any) -> int: