Skip to content

Lstopo translator#36

Open
Amos-Rai-KEYS wants to merge 18 commits intomainfrom
lstopo-translator
Open

Lstopo translator#36
Amos-Rai-KEYS wants to merge 18 commits intomainfrom
lstopo-translator

Conversation

@Amos-Rai-KEYS
Copy link
Collaborator

Translates hwloc lstopo to Infragraph

Copy link
Collaborator

@ajbalogh ajbalogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add notebooks to ci so they don't become out of date

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"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lspci - remove the entry

["lstopo", "-f" ,"--of", "xml", str(tmp_xml)],
check=True
)
input_file = str(tmp_xml)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean the temp folder and xml

"""
if input_file is None:
tmp_xml = Path(tempfile.gettempdir()) / "lstopo_output.xml"
subprocess.run(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate if lstopo is present? throw relevant error message

@@ -0,0 +1,61 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot dump dict format - should be yaml or json

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyone running notebook will need the object - the user can use that object to convert to the specific type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be used in code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants