-
Notifications
You must be signed in to change notification settings - Fork 36
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
Generate new network graphs #93
Conversation
7ef1868
to
a5be661
Compare
|
The weighted tags mean that there will likely be more nodes with recent version numbers. We might want to add a more accurate distribution later, or allow users to pass their own distribution function into this |
a5be661
to
7d22709
Compare
@pinheadmz @josibake should we also allow node versionc constriants, "e.g >=0.21.1" or just leave as weighted random over all supported tags? |
066ec46
to
3e4b516
Compare
3e4b516
to
19a49c3
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
bitcoind should be free to make these decisions. I think once we have the p2p dns seeder (which can provide service flags) this will evolve on its own I dont love removing
this latter option i think is preferable but then i also think well need a directory of graph files and a "list" method for them ? |
README.md
Outdated
@@ -129,17 +129,17 @@ Once `warnet` is running it can be interacted with using the cli tool `warcli`. | |||
All `warcli` commands accept a `--network` option, which allows you to specify the warnet you want to control. | |||
This is set by default to `--network="warnet"` to simplify default operation. | |||
|
|||
To start an example warnet, with your venv active and the server running, run the following command to use the default graph and network: | |||
To start a random warnet, with your venv active and the server running, run the following command to create 20 nodes where each edge has a 30% chance of being connected: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add this instead of replace the example graph method?
a little confused. you didnt remove/replace the |
Whilst the p2p dns seeder will certainly help in making connections, the bitcoind container cannot decide it's own binary version number it's going to run? This PR is about generating a graph file of randomised (or not) node:versions... My question was about whether we should have
Should we simply remove the grammar at this point, if we are not going to use it for everything? Currently we have:
@josibake felt like I am very happy to go with the majority, but I think we should spec out exactly how we want this to operate so that we can build it just so! My personal perference would be to retain the sub-commands (but use them in all cases), but happy to be out-voted on this one... edit: perhaps on a re-read now, I see that you would be for having |
ok yeah we got wires crossed.
|
Just poppin in to say ignore what I was saying earlier, been playing around with the CI more and got a feel for it. I do think more detailed help messages could alleviate any "un-intuitiveness" |
19a49c3
to
0140d56
Compare
OK how about this push? New sub-command try
|
Yeah I think we could add an
See latest force-push, again, happy to be overruled on this, but perhaps |
0140d56
to
f14f15d
Compare
src/warnet/warnetd.py
Outdated
graph = create_graph_with_probability(num_nodes, probability) | ||
if file: | ||
file = Path(file) | ||
networkx.write_graphml(graph, file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any options for this? the file works but is a little different than im used to seeing thus far which might make manual editing a bit more confusing e.g.
<key id="d1" for="node" attr.name="bitcoin_config" attr.type="string" />
<key id="d0" for="node" attr.name="version" attr.type="string" />
...
<data key="d0">24.1</data>
<data key="d1" />
src/warnet/cli/network.py
Outdated
@network.command() | ||
@click.argument("graph_file", default=EXAMPLE_GRAPH_FILE, type=click.Path()) | ||
@click.option("--force", default=False, is_flag=True, type=bool) | ||
@click.option("--network", default="warnet", show_default=True) | ||
def start( | ||
def from_graph( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be time to get rid of this default graph, especially for a command called "from graph", i think it should require an argument.
If we do include a new directory src/graphs
with files like sens_relay.graphml
and all_released_versions.graphml
etc they are more than just examples they are like standards. Would it be insane to call them "examples" and then have commands
warcli network list_examples
and
warcli network from_example sens_relay
?
This would be IN ADDITION to warcli network from_graph <whatever>
which would explicitly require an external file provided by the user
src/warnet/cli/network.py
Outdated
graph_file: Path = EXAMPLE_GRAPH_FILE, force: bool = False, network: str = "warnet" | ||
): | ||
""" | ||
Start a warnet with topology loaded from a <graph_file> into <--network> (default: "warnet") | ||
Create a warnet with topology loaded from a <graph_file> into <--network> (default: "warnet") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need to drop the default network as well. for example just now i ran a warnet then closed it, then tried to start a new warnet from a new graph and got this:
Config dir /Users/matthewzipkin/.warnet/warnet/warnet already exists, not overwriting existing warnet without --force
Maybe the dir could be something like...
~/.warnet/networks/<graphml file name?>
@@ -31,6 +31,8 @@ | |||
"0.16.3", | |||
"0.15.2", | |||
] | |||
WEIGHTED_TAGS = [tag for index, tag in enumerate(reversed(SUPPORTED_TAGS)) for _ in range(index + 1)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...or you could just list the versions in SUPPORTED_TAGS
in order of weight?
src/warnet/warnetd.py
Outdated
except Exception as e: | ||
logger.error(f"Exception {e}") | ||
@jsonrpc.method() | ||
def update_dns_seeder(graph_file: str, network: str = "warnet") -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its a bit tricky to review moved code, did this function change?
f14f15d
to
6bdba96
Compare
a03aa42
to
bbded03
Compare
9d8998a
to
2176876
Compare
2176876
to
b2126dd
Compare
b2126dd
to
5e9c202
Compare
@pinheadmz updated this for you |
delete random AS graphs of size `n` using either default tag (latest) or random tags from SUPPORTED_TAGS
5e9c202
to
5ead3a2
Compare
need to add lxml to requirements |
|
||
|
||
@graph.command() | ||
@click.argument("params", nargs=-1, type=str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets just require --n=<integer>
right? there's no other params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep agree.
Although... if we ever extend it to other graph types which do have more params, I think this is useful to leave in.
Personally, I feel like it's not much code, which does no harm currently, and I'd prefer to leave it as it's written up now for the future?
Easily persuaded that's not the best course of action here though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just weird to me to suddenly have an arg without the --
. And also, I think filename should either be required, or there should be a flag to pipe the output right back in to network start
. Would anyone need a 100 node graph file printed to the console?
|
||
logger.debug(f"Parsed params: {kwargs}") | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO most of the try/catch you have in this function should be removed so the error gets thrown back to the RPC caller. Otherwise you get a nice log message but all the CLI shows is "server error"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, this is an attempt. I actually don't recall why now I needed it at all. IIRC during some of my testing some graphs were breaking without it. But could have been an artefact of the nargs
optional cli args thingy (i.e. dodgy input coming from terminal?)
Perhaps if we want to actually return exceptions back to the user via CLI (do we though!?) we should have a refactor PR which moves all try/except into server.py? Each server function wraps function calls with them and can then either returns success, or any bubbled up exception (can also remove our dodgy decorator at the same time?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just execute warcli graph create
with no arguments.
User gets this:
Error generating graph: Server error
Logs get all this. Which starts off making sense (missing an arg) but ends up in a really weird place...
2023-11-01 17:42:21,811 - utils - ERROR - Failed to create graph: random_internet_as_graph() missing 1 required positional argument: 'n'
2023-11-01 17:42:21,846 - warnet.server - ERROR - unexpected error
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/flask_jsonrpc/site.py", line 135, in handle_dispatch_except
return self.dispatch(req_json)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/flask_jsonrpc/site.py", line 184, in dispatch
resp_view = current_app.ensure_sync(view_func)(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/typeguard/__init__.py", line 1033, in wrapper
retval = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/matthewzipkin/Desktop/work/warnet/src/warnet/server.py", line 291, in graph_generate
nx.write_graphml(graph, bio)
File "/opt/homebrew/lib/python3.11/site-packages/networkx/utils/decorators.py", line 766, in func
return argmap._lazy_compile(__wrapper)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<class 'networkx.utils.decorators.argmap'> compilation 9", line 5, in argmap_write_graphml_lxml_5
import itertools
^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/networkx/readwrite/graphml.py", line 176, in write_graphml_lxml
writer = GraphMLWriterLxml(
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/networkx/readwrite/graphml.py", line 745, in __init__
self.add_graph_element(graph)
File "/opt/homebrew/lib/python3.11/site-packages/networkx/readwrite/graphml.py", line 751, in add_graph_element
if G.is_directed():
^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'is_directed'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I hear ya, we might need an RPC overhaul to clean up some try
's. I think we are inconsistent with it.
Works for me without that (tm) 🤷🏼♂️ |
Graph CI won't create a network and errors heavily on teardown. Add a flag to TestBase which can bypass this. Also add a thread to read server stdout into test logs. And tear this thread down in the correct order to not block.
c68d1a0
to
819143e
Compare
OK ready FR FR |
hm yeah i didnt get the lxml error this time... ooooohhhkkkaaayyyyyy |
819143e
to
d3c63c6
Compare
YES. |
Generate
networkx.random_internet_as_graph
-type graphs using CLI.e.g.