Home › Forums › FABRIC General Questions and Discussion › Unable to add nodes to slice
- This topic has 4 replies, 3 voices, and was last updated 10 months, 2 weeks ago by Vaiden Logan.
-
AuthorPosts
-
January 10, 2024 at 9:51 am #6289
Hello, I am trying to add two nodes to my slice using the code below. However, I get an error: NetworkXError: GraphML writer does not support <class ‘list’> as data values. Could I get some help in understanding how to fix this? I’ve included the full error below the code.
slice_modified = fablib.get_slice(name=slice_name)
avoid_sites = [‘STAR’]
site_5 = fablib.get_random_sites(count=1,filter_function=lambda x:x[‘ptp_capable’] is True, avoid=(avoid_sites))
node5 = slice_modified.add_node(name=node5_name, site=site_5, cores=16, ram=32, disk=75, image=’default_ubuntu_22′)
node5_nic = node5.add_component(model=’NIC_Basic’, name=node5_nic_name).get_interfaces()[0]
node5_net = slice_modified.add_l3network(name=network5_name, interfaces=[node5_nic], type=’IPv4′)site_6 = fablib.get_random_sites(count=1,filter_function=lambda x:x[‘ptp_capable’] is True, avoid=(avoid_sites))
node6 = slice_modified.add_node(name=node6_name, site=site_6, cores=16, ram=32, disk=75, image=’default_ubuntu_22′)
node6_nic = node6.add_component(model=’NIC_Basic’, name=node6_nic_name).get_interfaces()[0]
node6_net = slice_modified.add_l3network(name=network6_name, interfaces=[node6_nic], type=’IPv4′)slice_modified.submit()
NetworkXError Traceback (most recent call last) Cell In[16], line 13 10 node6_nic = node6.add_component(model='NIC_Basic', name=node6_nic_name).get_interfaces()[0] 11 node6_net = slice_modified.add_l3network(name=network6_name, interfaces=[node6_nic], type='IPv4') ---> 13 slice_modified.submit() File /opt/conda/lib/python3.10/site-packages/fabrictestbed_extensions/fablib/slice.py:1961, in Slice.submit(self, wait, wait_timeout, wait_interval, progress, wait_jupyter, post_boot_config, wait_ssh, extra_ssh_keys) 1958 progress = False 1960 # Generate Slice Graph -> 1961 slice_graph = self.get_fim_topology().serialize() 1963 # Request slice from Orchestrator 1964 if self._is_modify(): File /opt/conda/lib/python3.10/site-packages/fim/user/topology.py:466, in Topology.serialize(self, file_name, fmt) 458 def serialize(self, file_name: str = None, fmt: GraphFormat = GraphFormat.GRAPHML) -> str or None: 459 """ 460 Serialize to string or to file, depending on whether file_name 461 is provided. (...) 464 :return string containing GraphML if file_name is None: 465 """ --> 466 graph_string = self.graph_model.serialize_graph(format=fmt) 467 if file_name is None: 468 return graph_string File /opt/conda/lib/python3.10/site-packages/fim/graph/networkx_property_graph.py:375, in NetworkXPropertyGraph.serialize_graph(self, format) 373 if graph is not None: 374 if format == GraphFormat.GRAPHML: --> 375 graph_string = '\n'.join(nx.generate_graphml(graph)) 376 graph_string = GraphML.networkx_to_neo4j(graph_string) 377 elif format == GraphFormat.JSON_NODELINK: File /opt/conda/lib/python3.10/site-packages/networkx/readwrite/graphml.py:231, in generate_graphml(G, encoding, prettyprint, named_key_ids, edge_id_from_attribute) 195 """Generate GraphML lines for G 196 197 Parameters (...) 223 edges together) hyperedges, nested graphs, or ports. 224 """ 225 writer = GraphMLWriter( 226 encoding=encoding, 227 prettyprint=prettyprint, 228 named_key_ids=named_key_ids, 229 edge_id_from_attribute=edge_id_from_attribute, 230 ) --> 231 writer.add_graph_element(G) 232 yield from str(writer).splitlines() File /opt/conda/lib/python3.10/site-packages/networkx/readwrite/graphml.py:650, in GraphMLWriter.add_graph_element(self, G) 647 for xml_obj, data in self.attributes.items(): 648 for k, v, scope, default in data: 649 xml_obj.append( --> 650 self.add_data( 651 str(k), self.attr_type(k, scope, v), str(v), scope, default 652 ) 653 ) 654 self.xml.append(graph_element) File /opt/conda/lib/python3.10/site-packages/networkx/readwrite/graphml.py:562, in GraphMLWriter.add_data(self, name, element_type, value, scope, default) 557 """ 558 Make a data element for an edge or a node. Keep a log of the 559 type in the keys table. 560 """ 561 if element_type not in self.xml_type: --> 562 raise nx.NetworkXError( 563 f"GraphML writer does not support {element_type} as data values." 564 ) 565 keyid = self.get_key(name, self.get_xml_type(element_type), scope, default) 566 data_element = self.myElement("data", key=keyid) NetworkXError: GraphML writer does not support <class 'list'> as data values.
January 10, 2024 at 10:47 am #6291Do you know what version of fablib you may be using ?
January 10, 2024 at 11:14 am #6292Vaiden,
The following line from your example returns a list of site names. This is true even if it returns only one site in the list.
site_5 = fablib.get_random_sites(count=1,filter_function=lambda x:x[‘ptp_capable’] is True, avoid=(avoid_sites))
When you pass it to
add_node
in the following line, you are passing a list as the site argument. That argument need to be a string.node5 = slice_modified.add_node(name=node5_name, site=site_5, cores=16, ram=32, disk=75, image=’default_ubuntu_22′)
Paul
January 10, 2024 at 11:20 am #62931.6.0
January 10, 2024 at 11:24 am #6294Thanks Paul. That fixed it!
-
AuthorPosts
- You must be logged in to reply to this topic.