Skip to content

Instantly share code, notes, and snippets.

@noklam
Last active September 6, 2023 12:40
Show Gist options
  • Save noklam/2259fa3342071a68c395487906d8f135 to your computer and use it in GitHub Desktop.
Save noklam/2259fa3342071a68c395487906d8f135 to your computer and use it in GitHub Desktop.
A handy script for debugging Kedro Project to print all necessary information - inspired by https://github.com/fastai/fastai1/blob/master/fastai/utils/show_install.py
def show_install(show_nvidia_smi: bool = False):
"Print user's setup information"
import kedro, kedro_datasets, platform, os, sys
rep = []
opt_mods = []
rep.append(["=== Software ===", None])
rep.append(["python", platform.python_version()])
rep.append(["kedro", kedro.__version__])
rep.append(["kedro_datasets", kedro_datasets.__version__])
def get_env(name):
"Return env var value if it's defined and not an empty string, or return Unknown"
res = os.environ.get(name, "")
return res if len(res) else "Unknown"
rep.append(["\n=== Environment ===", None])
rep.append(["platform", platform.platform()])
if platform.system() == "Linux":
distro = try_import("distro")
if distro:
# full distro info
rep.append(["distro", " ".join(distro.linux_distribution())])
else:
opt_mods.append("distro")
# partial distro info
rep.append(["distro", platform.uname().version])
rep.append(["conda env", get_env("CONDA_DEFAULT_ENV")])
rep.append(["python", sys.executable])
rep.append(["sys.path", "\n".join(sys.path)])
print("\n\n```text")
keylen = max([len(e[0]) for e in rep if e[1] is not None])
for e in rep:
print(f"{e[0]:{keylen}}", (f": {e[1]}" if e[1] is not None else ""))
# Kedro Project info
from kedro.framework.startup import bootstrap_project
metadata = bootstrap_project("/Users/Nok_Lam_Chan/tmp/iris")
print(metadata)
import iris
for k, v in vars(iris.settings).items():
if k.startswith("__"):
continue
print(f"{k=} {v=}")
print("```\n")
# Print Plugin Info
from collections import defaultdict
from kedro.framework.cli.utils import _get_entry_points, ENTRY_POINT_GROUPS
plugin_versions = {}
plugin_entry_points = defaultdict(set)
for plugin_entry_point in ENTRY_POINT_GROUPS:
for entry_point in _get_entry_points(plugin_entry_point):
module_name = entry_point.module.split(".")[0]
plugin_versions[module_name] = entry_point.dist.version
plugin_entry_points[module_name].add(plugin_entry_point)
print(
"Please make sure to include opening/closing ``` when you paste into forums/github to make the reports appear formatted as code sections.\n"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment