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

chore: Adding neuroglancer utility #381

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions ingestion_tools/scripts/neuroglancer_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import json
import urllib.parse
import webbrowser

import click
import cryoet_data_portal as cdp

STAGING_GRAPHQL_URL = "https://genuine-satyr.staging-cryoet.staging.czi.team/graphql"
STAGING_FILESERVER = "https://files.cryoet.staging.si.czi.technology/"

PROD_FILESERVER = "https://files.cryoetdataportal.cziscience.com/"


@click.group()
@click.pass_context
def cli(ctx):
pass


def print_neuroglancer_links(run_id: int, client: cdp.Client, dest_fileserver: str, print_link: bool):
run = cdp.Run.get_by_id(client, run_id)
for tomogram in run.tomograms:
if neuroglancer_config := tomogram.neuroglancer_config:
new_config = neuroglancer_config.replace(PROD_FILESERVER, dest_fileserver)
config_json = json.loads(new_config)
ng_url = "https://neuroglancer-demo.appspot.com/#!" + urllib.parse.quote(
json.dumps(config_json, separators=(",", ":")),
)
if print_link:
print(f"Tomogram id={tomogram.id} processing={tomogram.processing}")
print(ng_url + "\n" * 3)
webbrowser.open(ng_url, new=0, autoraise=True)


@cli.command()
@click.argument("run_id", required=True, type=int)
@click.argument("graphql_url", required=False, type=str, default=STAGING_GRAPHQL_URL)
@click.argument("output_fileserver", required=False, type=str, default=STAGING_FILESERVER)
@click.option("--print-link", type=bool, is_flag=True, default=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add docs for these?

def translate_env(run_id: int, graphql_url, output_fileserver: str, print_link: bool):
print_neuroglancer_links(run_id, cdp.Client(graphql_url), output_fileserver, print_link)


if __name__ == "__main__":
cli()
Loading