FlyWire access check¶
Not an analysis.
It answers two questions before real work:
does this machine have permission to query CAVE,
and do the local census ids exist on the server?
The public datastack is frozen at release 783 and has six tables;
cell types are not one of them (they come from Codex, see
collect).
class Inventory(NamedTuple):
"""What the server reports: the materialization versions, the
version in use, and the table names."""
versions: list
version: int
tables: list
def check_inventory(m) -> Inventory:
"""Materialization versions and table names the server reports."""
return Inventory(
versions=m.get_versions(), version=m.version, tables=m.get_tables()
)
Sample the core tables¶
nuclei_v1: one cell body. Its position ispt_position, andsplit_positions=Truegives x, y, z.Sources.SYNAPSE_VIEW: one synapse. Every connection count comes from this view; it is a view, soget_tablesdoes not list it.Sources.TRANSMITTER_TABLE: one synapse, with per-transmitter probabilities and no singlent_typecolumn.
def sample_tables(m):
"""Three nuclei rows, one row of the synapse view, and one row of
the transmitter table, to prove all three answer."""
nuclei = m.query_table(
"nuclei_v1",
select_columns=["pt_root_id", "pt_position"],
limit=3,
split_positions=True,
)
view_row = m.query_view(Sources.SYNAPSE_VIEW, limit=1)
synapse = m.query_table(Sources.TRANSMITTER_TABLE, limit=1)
return nuclei, view_row, synapse
ancestor-stopped: This cell wasn't run because an ancestor was stopped with `mo.stop`:
ancestor-stopped: This cell wasn't run because an ancestor was stopped with `mo.stop`:
ancestor-stopped: This cell wasn't run because an ancestor was stopped with `mo.stop`:
Do the census LC16 ids exist on the server?¶
The Codex census and the CAVE tables are separate products.
Every census LC16 id is looked up in nuclei_v1;
most should resolve, and zero means the two disagree on the
release.
def lc16_in_nuclei(m, census) -> int:
"""Number of census LC16 root ids found in nuclei_v1."""
ids = root_ids_of_type(census, "LC16")
hit = m.query_table(
"nuclei_v1",
filter_in_dict={"pt_root_id": ids},
select_columns=["pt_root_id"],
)
return int(hit["pt_root_id"].nunique())
_census = load_census()
_found = lc16_in_nuclei(m, _census)
_total = len(root_ids_of_type(_census, "LC16"))
mo.md(f"**{_found}** of {_total} census LC16 ids found in `nuclei_v1`.")
ancestor-stopped: This cell wasn't run because an ancestor was stopped with `mo.stop`:
On a login error¶
On 401, 403, or anything mentioning a token, create one at https://global.daf-apis.com/auth/api/v1/create_token, then save it with the global client, not the datastack client. A new token invalidates the old one.
from caveclient import CAVEclient
client = CAVEclient(server_address="https://global.daf-apis.com")
client.auth.save_token("<TOKEN>", overwrite=True)
def main() -> None:
"""Batch: run every check, printing results; exit 1 with token
hints on failure."""
try:
m = cave_materialize()
inventory = check_inventory(m)
print(f"version {inventory.version}; tables {inventory.tables}")
nuclei, view_row, synapse = sample_tables(m)
print(
f"nuclei_v1 ok ({len(nuclei)} rows); "
f"{Sources.SYNAPSE_VIEW} columns {list(view_row.columns)}; "
f"{Sources.TRANSMITTER_TABLE} columns {list(synapse.columns)}"
)
print(f"LC16 ids in nuclei_v1: {lc16_in_nuclei(m, load_census())}")
except Exception as e: # a smoke test reports any failure
print(f"FAILED: {type(e).__name__}: {e}")
if "401" in str(e) or "403" in str(e) or "token" in str(e).lower():
print(
"token missing or expired; "
"see the last section of this notebook"
)
if "503" in str(e):
print("materialize host is down")
sys.exit(1)