Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

processing error with create.network_data.from.file module (gml) #27

Open
yaslena opened this issue Apr 13, 2023 · 4 comments
Open

processing error with create.network_data.from.file module (gml) #27

yaslena opened this issue Apr 13, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@yaslena
Copy link
Collaborator

yaslena commented Apr 13, 2023

Describe the bug
When trying to create network data from a gml file that does not have "label" attributes networkX will throw a processing error "node #0 has no 'label' attribute".

To Reproduce
Steps to reproduce the behavior:

  1. Onboard karate.gml file in kiara with import.local.file module from filepath.
  2. Run create.network_data.from.file with the onboarded gml file.
  3. See error "Processing error"

Expected behavior
If a gml file does not have a label attribute, it should be possible to set label attribute to id. Every gml file will at least have node ids; labels are optional. However, label should not be set to id by default, because otherwise existing label information is not onboarded.

My temporary solution was to add an optional "label" input for onboarding gml file format.

Desktop (please complete the following information):

  • OS: macOS Ventura Version 13.2.1
  • kiara command line app in Terminal
@makkus
Copy link
Collaborator

makkus commented Apr 13, 2023

Do you think it'd be fair to assume that if a gml file has no 'label' attribute, the 'id' attribute should be used? Or could the node_id in a gml file also have a different name than 'id'?

The reason I'm asking is, we could make it easier for users by trying to import a gml file as is, without the label input option, and if we get a processing error we try again, this time with label set to 'id'. This would only work if the 'id' field can be relied upon to exist. And also that if there is a label, the attribute is called 'label'. Which, if I think about it, is probably not the case, since otherwise networkx wouldn't let us specify a custom one?

@yaslena
Copy link
Collaborator Author

yaslena commented Apr 13, 2023

Apparently, node "id" cannot be relied upon to exist for all nodes, because the field is not necessary for isolated nodes (nodes that are not connected to any other nodes). (Reference: https://intranet.icar.cnr.it/wp-content/uploads/2018/12/RT-ICAR-PA-2018-06.pdf). Although, in that case networkX will also throw an error: node #X has no 'id' attribute.
The node "id" cannot be called anything else but "id", but it does not need to be an integer.

Also "label" can be entirely missing or there could be a "name" field which has the same function. (Reference: http://docs.yworks.com/yfiles/doc/developers-guide/gml.html). After some experimenting, "label" seems to be an entirely custom field that could be called anything ('tag', 'description', or whatever).

Apart from all possible gml file variations, I have never seen a gml file without node ids.

@makkus
Copy link
Collaborator

makkus commented Apr 13, 2023

Ok, I guess it doesn't hurt to just try again with the 'id' string as 'label'. If it doesn't work, we'd have needed another input anyway, and if it does, we at least have a valid 'network_data' dataset. And even if it has a potentially incorrect label (but I'd guess it's more often we have no label than one that isn't using the 'label' attribute), we can always have a module that can 'clean' up those kind of things (which we'll need anyway I think).

The strategy I'm going for here is that it's better to have a good chance of something working without needing any additional user input (that could be confusing, cluttering up our UI, even though it would not be needed in a majority of the cases). If our bet is wrong, and most of the cases are very specific, then we have to have a more powerful module anyway, but at least we'll have some evidence that it's necessary, and a good idea what it needs to be able to handle.

Anyway, I'll implement this 'try with 'id' label if it fails' case for the next version, and then we'll see where we are at.

@makkus
Copy link
Collaborator

makkus commented Apr 13, 2023

Actually, I can add a 3rd one if the 2nd one fails, which tries the 'name' attribute.

@yaslena yaslena added the bug Something isn't working label Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants