Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with NetworkX when using graph subindex #664

Closed
arkim822 opened this issue Feb 12, 2024 · 6 comments
Closed

Issues with NetworkX when using graph subindex #664

arkim822 opened this issue Feb 12, 2024 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@arkim822
Copy link

Hello. Apologies for posting something like this but I am unable to figure out what I'm doing wrong when trying to use the subindex. I keep getting this error message:

ImportError: NetworkX is not available - install "graph" extra to enable

And I have tried to solve it by running these commands (Ubuntu/Linux environment)

sudo apt-get install graphviz libgraphviz-dev
pip install pygraphviz pydot lxml
pip install networkx
pip install networkx[extra]

This is the code I'm running

import txtai
embeddings = txtai.Embeddings(
    content=True,
    defaults=False,
    functions=[
        {"name": "graph", "function": "indexes.act.graph.attribute"}
    ],
     expressions=[
         {"name": "topic", "expression": "graph(indexid, 'topic')"},
     ],
    indexes={
        "dataset_name": {
            "keyword": True,
            "columns": {
                "text": "dataset_name"
            },
            "graph": {
                "topics": {}
            }
        },
        "zeno_link":{
            "columns": {
                "text": "zeno_link"
            }
        },
        "all_text":{
            "columns": {
                "text": "all_text"
            }
        }
    }
)
embeddings.index(alltext_dataset)

embeddings.search("select id, dataset_name, zeno_link, all_text, score from txtai where similar('Linux terminal')", 1)

txtai==6.3.0
networkx==3.2.1

@davidmezzetti
Copy link
Member

What if you run:

pip install txtai[graph]

@arkim822
Copy link
Author

Thank you @davidmezzetti !! That did it :D

Really appreciate the help. Would it be a good idea for me to add this to the subindex notebook?

@davidmezzetti
Copy link
Member

What is the exact notebook again?

@arkim822
Copy link
Author

One of them is:
https://github.com/neuml/txtai/blob/master/examples/46_Whats_new_in_txtai_6_0.ipynb

I can keep scanning for more and open a PR, as well.

@davidmezzetti
Copy link
Member

Don't worry about it. I'll take a look and update as appropriate. Thank you for the heads up.

@davidmezzetti davidmezzetti self-assigned this Feb 20, 2024
@davidmezzetti davidmezzetti added this to the v7.0.0 milestone Feb 20, 2024
@davidmezzetti davidmezzetti added the bug Something isn't working label Feb 20, 2024
@davidmezzetti
Copy link
Member

Colab removed some libraries that were installed previously causing graph notebooks to fail unless they install the graph extra. The graph extra should be installed when using graphs regardless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants