-
Notifications
You must be signed in to change notification settings - Fork 0
Modular wait for + Notebooks #5
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
Open
LucaVor
wants to merge
4
commits into
main
Choose a base branch
from
modularWaitFor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -35,11 +35,15 @@ The `MantisClient` object requires the parameter `cookie` to be passed in. This | |||||
| ***Note***: If you are using a local backend, you must run it with docker, or the space creation will NOT work. To do so, `cd docker` from the backend root, then `docker compose up -d --build`. After you run the build once, you can re-run it simply with `docker compose up`. If things dno't work, check the logs and make sure they are not empty. | ||||||
|
|
||||||
| ```python | ||||||
| from client import MantisClient, SpacePrivacy, DataType, ReducerModels | ||||||
| from render_args import RenderArgs | ||||||
| from mantis_sdk.client import MantisClient, SpacePrivacy, DataType, ReducerModels | ||||||
| from mantis_sdk.render_args import RenderArgs | ||||||
| from mantis_sdk.config import ConfigurationManager | ||||||
| import pandas as pd | ||||||
|
|
||||||
| mantis = MantisClient("/api/proxy/", cookie) | ||||||
| # You need to provide your cookie and a space_id (can be dummy for creation) | ||||||
| cookie = "YOUR_COOKIE_HERE" | ||||||
|
|
||||||
| mantis = MantisClient("/api/proxy/", cookie=cookie, space_id="dummy") | ||||||
|
|
||||||
| # Create DF (Real data will need more points) | ||||||
| df = pd.DataFrame({ | ||||||
|
|
@@ -58,10 +62,11 @@ new_space_id = mantis.create_space("Stock data", | |||||
| data=df, | ||||||
| data_types=data_types, | ||||||
| reducer=ReducerModels.UMAP, | ||||||
| privacy_level=SpacePrivacy.Private)["space_id"] | ||||||
| privacy_level=SpacePrivacy.PRIVATE)["space_id"] | ||||||
|
|
||||||
| # Open space | ||||||
| space = await mantis.open_space(space_id) | ||||||
| # Re-initialize client with the new space_id if needed, or just use the space object | ||||||
| space = await mantis.open_space(new_space_id) | ||||||
|
|
||||||
| # Interact with space | ||||||
| await space.select_points(100) | ||||||
|
|
@@ -166,4 +171,39 @@ await space.run_code (code) | |||||
| await space.close_panel ("bags") | ||||||
| await space.close_panel ("quicksheet") | ||||||
| await space.close_panel ("userlogs") | ||||||
| ``` | ||||||
|
|
||||||
| ### Notebooks | ||||||
|
|
||||||
| You can create and manage notebooks within a space. | ||||||
|
|
||||||
| ```python | ||||||
| # Create a notebook | ||||||
| nb = mantis.create_notebook(space_id, "My Analysis", "user_id") | ||||||
|
|
||||||
| # Add a cell | ||||||
| code = """ | ||||||
| print("Hello from Mantis Notebook!") | ||||||
| """ | ||||||
| cell = nb.add_cell(code) | ||||||
|
|
||||||
| # Execute cell | ||||||
| outputs = cell.execute() | ||||||
| print(outputs) | ||||||
| ``` | ||||||
|
|
||||||
| ### Configuration | ||||||
|
|
||||||
| You can configure the client using `ConfigurationManager`. | ||||||
|
|
||||||
| ```python | ||||||
| from mantis_sdk.config import ConfigurationManager | ||||||
|
|
||||||
| config = ConfigurationManager() | ||||||
| config.update({ | ||||||
| "timeout": 60000, | ||||||
| "render_args": RenderArgs(headless=True) | ||||||
| }) | ||||||
|
|
||||||
| mantis = MantisClient("/api/proxy/", cookie=cookie, space_id=space_id, config=config) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| ``` | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In this example snippet, the
space_idvariable is used but it has not been defined within this context. To make the example runnable and clearer for users, you should usenew_space_id, which is created in the "Quick Start" example earlier in the document.