Conversation
ajbalogh
left a comment
There was a problem hiding this comment.
add notebooks to ci so they don't become out of date
…graph into lstopo-translator
| from infragraph.translators.lstopo_translator import run_lstopo_parser | ||
|
|
||
| def run_translator(tool: str, input_file: str, output_path: str, dump_format: str) -> str: | ||
| supported_translators = ["lstopo", "lspci"] |
There was a problem hiding this comment.
lspci - remove the entry
| ["lstopo", "-f" ,"--of", "xml", str(tmp_xml)], | ||
| check=True | ||
| ) | ||
| input_file = str(tmp_xml) |
There was a problem hiding this comment.
clean the temp folder and xml
| """ | ||
| if input_file is None: | ||
| tmp_xml = Path(tempfile.gettempdir()) / "lstopo_output.xml" | ||
| subprocess.run( |
There was a problem hiding this comment.
validate if lstopo is present? throw relevant error message
| @@ -0,0 +1,61 @@ | |||
| { | |||
There was a problem hiding this comment.
should we try with the #%% syntax? Maybe not add notebook as .ipynb file but just .py files?
| @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(["dict", "json", "yaml"]), default="yaml") |
There was a problem hiding this comment.
cannot dump dict format - should be yaml or json
There was a problem hiding this comment.
maybe try adding toon format?
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "lstopo_parser = run_lstopo_parser(input_file=lstopo_xml_file, output_file=\"dev.json\", dump_format=\"json\")\n", |
There was a problem hiding this comment.
anyone running notebook will need the object - the user can use that object to convert to the specific type.
There was a problem hiding this comment.
use parser.parse() - return the object and use serializer in next cell, so code should be:
parser = LstopoParser(input_file)
device_model = parser.parse()| bridge_map, bridge_count, root_count = self._build_pci_bridge_dict() | ||
| self._create_bridge_components(root_count, bridge_count) | ||
| self._create_topology_edges(bridge_map) | ||
| return self.device |
There was a problem hiding this comment.
should we return infragraph obj: single device data with single instance and no global edges? @ajbalogh
| self.pcidevice_is_nvslw: Dict[str, List[str]] = {} | ||
| self.package_to_root_map: Dict[str, int] = {} | ||
|
|
||
| def parse(self) -> Device: |
There was a problem hiding this comment.
maybe add another parameter: infra_type: "device" or "infragraph", default being "infragraph"
| edge.ep2.component = f"{self.nvlsw.name}[{nvswitch_key[5:]}]" | ||
|
|
||
|
|
||
| def run_lstopo_parser( |
There was a problem hiding this comment.
this is the root call for cli
| if not os.path.isfile(input_file): | ||
| raise FileNotFoundError(f"Input file not found: {input_file}") | ||
|
|
||
| parser = LstopoParser(input_file) |
There was a problem hiding this comment.
this will be used in code
Translates hwloc lstopo to Infragraph