Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ src/infragraph/infragraph.py
src/infragraph/infragraph_pb2*
src/docs
docs/src/yaml
*.lib
*.html
*.txt
src/tests/printed/*
src/hwloc/devices_xml
src/hwloc/devices_svg
dev.json
src/tests/test_notebooks/
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ generate: ## generate artifacts using OpenApiArt
test: ## run unit tests on the src/infragraph files
source .venv/bin/activate && \
pip uninstall -y infragraph && \
make pre-test-notebook && \
pytest -s

.PHONY: package
package: generate ## create sdist/wheel packages from OpenAPIArt generated artifacts
rm -rf dist || true
Expand Down Expand Up @@ -54,3 +55,10 @@ docs: ## generate local documentation to docs/site
yaml: ## generate yaml contents for docs
source .venv/bin/activate && \
python3 docs/generate_yaml.py

.PHONY: pre-test-notebook
pre-test-notebook:
rm -rf src/tests/test_notebooks
jupytext --to notebook src/infragraph/notebooks/*.py
cd src && python3 notebook_to_test_script.py
rm -rf src/infragraph/notebooks/*.ipynb
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ twine
mkdocs
mkdocs-material
mkdocs-include-markdown-plugin
mkdocs-print-site-plugin
mkdocs-print-site-plugin
jupytext
nbconvert
21 changes: 21 additions & 0 deletions src/infragraph/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import click
from infragraph.translators.translator_handler import run_translator


@click.group()
def cli():
pass

@cli.command()
@click.argument("tool", type=click.Choice(["lstopo", "lspci"]))
@click.option("-i", "--input", "input_file", help="Input file path")
@click.option("-o", "--output", "output_file", default="dev.yaml", help="Output file path")
@click.option("--dump", type=click.Choice(["json", "yaml"]), default="yaml")
def translator(tool, input_file, output_file, dump):
"""Run selected translator"""
run_translator(tool, input_file, output_file, dump)

# we can add some more cli.command() eg for visualizer.

if __name__ == "__main__":
cli()
16 changes: 16 additions & 0 deletions src/infragraph/notebooks/lstopo_translate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#%%
import os
from infragraph.translators.lstopo_translator import LstopoParser
from infragraph import *

#%%
current_dir = os.path.dirname(os.path.abspath(__file__))
mock_data_path = os.path.join(current_dir, "../../tests/test_translators/mock_data")
lstopo_xml_file = os.path.join(mock_data_path, "supermicro.xml")

#%%
lstopo_parser = LstopoParser(lstopo_xml_file)
infra_obj = lstopo_parser.parse()
print(infra_obj)

# %%
Loading
Loading