Skip to content

Commit 35add99

Browse files
committed
Add debug flag to cf ls
1 parent 49a04f6 commit 35add99

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

curifactory/experimental/cli.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# https://stackoverflow.com/questions/4042452/display-help-message-with-python-argparse-when-script-is-called-without-any-argu
44

55
import argparse
6+
import json
67
import logging
78
import os
89
from dataclasses import MISSING, fields
@@ -33,6 +34,11 @@ def main(): # noqa: C901
3334

3435
subparsers = parser.add_subparsers(help="Commands:", dest="command")
3536

37+
conf_parser = subparsers.add_parser(
38+
"config", help="View/edit curifactory configuration"
39+
)
40+
conf_parser.add_argument("--debug", "--verbose", action="store_true", dest="debug")
41+
3642
ls_parser = subparsers.add_parser("ls", help="List pipelines")
3743
ls_parser.add_argument("thing_to_list", nargs="?")
3844
ls_parser.add_argument(
@@ -45,6 +51,7 @@ def main(): # noqa: C901
4551
ls_parser.add_argument(
4652
"--paths", dest="list_paths", action="store_true", help="List artifact paths"
4753
)
54+
ls_parser.add_argument("--debug", "--verbose", action="store_true", dest="debug")
4855

4956
run_parser = subparsers.add_parser("run", help="Run an pipeline", add_help=False)
5057
run_parser.add_argument("pipeline").completer = completer_pipeline
@@ -338,6 +345,10 @@ def list_converter(string):
338345
# import subprocess
339346
# subprocess.run(["/usr/bin/kitty", "icat"], input=dot.pipe(format="kitty"))
340347

348+
elif parsed.command == "config":
349+
manager = cf.get_manager()
350+
print(json.dumps(manager.config, indent=4))
351+
341352
elif parsed.command == "map":
342353
manager = cf.get_manager()
343354
manager.load_default_pipeline_imports()
@@ -498,6 +509,11 @@ def list_converter(string):
498509

499510
elif parsed.command == "ls":
500511
manager = cf.get_manager()
512+
if parsed.debug:
513+
print("Yep it's debug")
514+
# logging.getLogger("curifactory").setLevel(logging.DEBUG)
515+
manager.logger.setLevel(logging.DEBUG)
516+
manager.init_root_logging()
501517

502518
if not parsed.list_runs:
503519
manager.load_default_pipeline_imports()
@@ -551,7 +567,7 @@ def list_converter(string):
551567
else:
552568
print(
553569
artifact.name.ljust(20),
554-
f"".ljust(40),
570+
"".ljust(40),
555571
f"(context: {artifact.context_name})".ljust(40),
556572
)
557573
else:

curifactory/experimental/manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ def load_default_pipeline_imports(self):
310310

311311
def import_pipelines_from_module(self, module_str: str):
312312
# try to load the module
313+
self.logger.debug(f"Attempting to import {module_str}")
313314
module = self.quietly_import_module(module_str)
314315
remainder = None
315316
while module is None:
@@ -363,6 +364,9 @@ def add_pipeline_to_ref_names(self, module_str: str, attr_name: str, pipeline):
363364
building_module_str = ".".join(module_pieces[-i:])
364365
self.pipeline_ref_names[f"{building_module_str}.{attr_name}"] = pipeline
365366
self.pipeline_ref_names[f"{building_module_str}.{pipeline.name}"] = pipeline
367+
self.logger.debug(
368+
f"Adding pipeline {pipeline.name} at {building_module_str}.{pipeline.name}"
369+
)
366370

367371
def divide_reference_parts(self, ref_str: str) -> dict[str, str]:
368372
parts = {"module": None, "pipeline": None, "artifact_filter": None}

0 commit comments

Comments
 (0)