Skip to main content

Share Graphs

When you create a graph via Graph(True) it is automatically synced to ZefHub. A local-only graph can also be synced via g | sync | run.

Synced graphs can be shared with other users.

Sharing graphs

To give other users access to your graph, you can run:

"joe.bloggs@gmail.com" | grant[KW.view][g] | run

The user joe.bloggs@gmail.com can then see your graph by its UID, i.e. they can then run:

g = Graph("<uid here>")

where the uid can be discovered by running uid(g).

Privileges that are allowed are:

  • KW.view: viewing (subscribing to) the graph contents.
  • KW.host: taking the host role of a graph.
  • KW.append: appending to the graph. This could be done by taking the host role or by sending merge requests.
  • KW.discover: seeing the graph's tags in zearch queries.
  • KW.modify_rights: changing the privileges of the graph.

To make a graph publically available, you can use:

"group:everyone" | grant[KW.view][g] | run

Tagging graphs

As sharing UIDs is tedious, you can also tag your graphs:

g | tag["secret-santa-planning"] | run

You and other users with viewing rights can then access this graph via Graph("<your-user-name>/secret-santa-planning").

Unless specified, your tags will be grouped into your user namespace. If you want to override this, you can provide a qualified name with extra / divisions:

g | tag["ACME-company/secret-santa-planning"] | run

Revoking access privileges

The revoke zefop is the opposite of grant:

"joe.bloggs@gmail.com" | revoke[KW.view][g] | run

Appending to a shared graph

If you have subscribed to a graph that you have append-privileges, then you can directly add new facts to the graph:

g = Graph("secret-santa-planning")

(ET.Participant, RT.Name, "Krampus") | g | run

This will cause a "merge request" to be sent via the network and wait for a successful response to be received.

If many rapid updates need to be applied, you should take the host role:

make_primary(g)
for i in range(1000):
ET.Participant | g | run
make_primary(g, False)

Acquiring host role means that all updates are performed in-memory with maximum speed. These updates are synchronized with ZefHub in a background process. Note that only one python process can have host role at any one time.

Future plans

In the future, graph tags will be made available via projects. So expect to see something similar to:

g = Graph()
g | sync["project-name"] | run
g | tag["specific-graph"] | run

g2 = Graph("project-name", "specific-graph")

g == g2