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

Fix WK-lib download snippet #6605

Merged
merged 4 commits into from
Nov 23, 2022
Merged
Changes from 3 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,27 @@ function _PythonClientModalView(props: Props): JSX.Element {
"loading...",
[activeUser],
);

const nonDefaultHost = !document.location.host.endsWith("webknossos.org");
const indention = "\n ";
const contextUrlAddendum = nonDefaultHost ? `, url="${window.location.origin}"` : "";
const maybeUrlParameter = nonDefaultHost
? `${indention}webknossos_url="${window.location.origin}"`
: "";

const wkInitSnippet = `import webknossos as wk

with wk.webknossos_context(token="${authToken || "<insert token here>"}"):
with wk.webknossos_context(token="${authToken || "<insert token here>"}"${contextUrlAddendum}):
# Download the dataset.
dataset = wk.Dataset.download(
webknossos_url="${window.location.origin}",
dataset_name_or_url="${dataset.name}",
organization_id="${dataset.owningOrganization}",
organization_id="${dataset.owningOrganization}",${maybeUrlParameter}
)
# Alternatively, directly open the dataset. Image data will be
# streamed when being accessed.
remote_dataset = wk.Dataset.open_remote(
webknossos_url="${window.location.origin}",
dataset_name_or_url="${dataset.name}",
organization_id="${dataset.owningOrganization}",
organization_id="${dataset.owningOrganization}",${maybeUrlParameter}
)
`;

Expand Down