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

Error Running Notebooks NetworkXError: random_state_index is incorrect #4

Closed
kevthehermit opened this issue Apr 11, 2021 · 7 comments
Closed

Comments

@kevthehermit
Copy link

This applies to several notebooks but using randomnetwork.ipynb as the example

Running the first two cells results in a couple of errors.

Cell contents

traffic = g.generate_random_traffic_network(
    seed=1, n_clients=50, 
    n_servers={
                "SMB": 15,
                "HTTP": 15,
                "RDP": 15,
            },
    alpha=np.array([(1, 1), (0.2, 0.5)], dtype=float),
    beta=np.array([(1000, 10), (10, 100)], dtype=float),
)

Ouptut from Cell

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/networkx/utils/decorators.py in _random_state(func, *args, **kwargs)
    451         try:
--> 452             random_state_arg = args[random_state_index]
    453         except TypeError:

IndexError: tuple index out of range

During handling of the above exception, another exception occurred:

NetworkXError                             Traceback (most recent call last)
<ipython-input-2-d4d566484044> in <module>
----> 1 traffic = g.generate_random_traffic_network(
      2     seed=1, n_clients=50,
      3     n_servers={
      4                 "SMB": 15,
      5                 "HTTP": 15,

/opt/CyberBattleSim/cyberbattle/simulation/generate_network.py in generate_random_traffic_network(n_clients, n_servers, seed, tolerance, alpha, beta)
     72 
     73         # sample edges using block models given edge probabilities
---> 74         di_graph_for_protocol = nx.stochastic_block_model(
     75             sizes=sizes, p=probs, directed=True, seed=seed)
     76 

/usr/local/lib/python3.8/dist-packages/decorator.py in fun(*args, **kw)
    229             if not kwsyntax:
    230                 args, kw = fix(args, kw, sig)
--> 231             return caller(func, *(extras + args), **kw)
    232     fun.__name__ = func.__name__
    233     fun.__doc__ = func.__doc__

/usr/local/lib/python3.8/dist-packages/networkx/utils/decorators.py in _random_state(func, *args, **kwargs)
    454             raise nx.NetworkXError("random_state_index must be an integer")
    455         except IndexError:
--> 456             raise nx.NetworkXError("random_state_index is incorrect")
    457 
    458         # Create a numpy.random.RandomState instance

NetworkXError: random_state_index is incorrect
@azom123
Copy link

azom123 commented Apr 11, 2021

Hhhhfddj

@br0kej
Copy link
Contributor

br0kej commented Apr 11, 2021

I ran into the same issue with several of the examples too and I think I may have found the problem. By default using the init.sh script provided, the version of the decorator package installed is 5.0.6 - This version seeks to fix a number of issues introduced in 5.0.* versions up to 5.0.5 which started breaking things in Networkx (See Networkx Issue #4718) I don't think it has been properly integrated into Networkx and they have pinned decorator at decorator>=4.4,<5 in the default requirements.txt. Something seems to be overwriting it!

The solution is to manually downgrade the decorator version to 4.3.0

Command:

pip install decorator==4.3

Doing this managed to fix the problems and allowed me to run all of the jupyter notebook examples! Hopefully works for you to @kevthehermit.

@kevthehermit
Copy link
Author

kevthehermit commented Apr 12, 2021

Thanks, @br0kej confirming that fixed the issue for me. Will leave this open until it gets fixed upstream.

@blumu
Copy link
Contributor

blumu commented Apr 30, 2021

@br0kej @kevthehermit Thank you both for reporting the issue and suggesting the fix. I see there is already a PR with a fix, I'll get it merged soon!

@blumu blumu closed this as completed Apr 30, 2021
@Mona-byte
Copy link

Thanks for the suggestion. I used conda install -c anaconda decorator==4.3

@habdullahjaved
Copy link

Thank you so much

1 similar comment
@habdullahjaved
Copy link

Thank you so much

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

No branches or pull requests

6 participants