Skip to content

Commit

Permalink
Refactor Store to Project (#325)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas S <thomas@probabl.ai>
Co-authored-by: Auguste Baum <auguste@probabl.ai>
  • Loading branch information
3 people authored Sep 17, 2024
1 parent 2899ef7 commit 8c70941
Show file tree
Hide file tree
Showing 131 changed files with 4,090 additions and 7,979 deletions.
12 changes: 9 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Bug reports are welcome, especially those reported with [short, self-contained,

### Quick start

You'll need Python>=3.12 to build the backend and Node>=20 to build the frontend. Then, you can install dependencies and run the dashboard with:
You'll need Python>=3.12 to build the backend and Node>=20 to build the frontend. Then, you can install dependencies and run the UI with:
```sh
make install
make build-frontend
make serve-dashboard
make serve-ui
```

You are now all setup to run the library locally.
Expand Down Expand Up @@ -55,7 +55,7 @@ in the `frontend` directory
Then, to use the frontend
```sh
make build-frontend
make serve-dashboard
make serve-ui
```

### Documentation
Expand All @@ -69,3 +69,9 @@ Then, you can access the local build via:
```sh
open doc/_build/html/index.html
```

## Help for common issues

### `make build-frontend` doesn't work!

Please check that your version of node is at least 20 using the following command: `node -v`
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ check-wip:

serve-api:
SKORE_ROOT=$(SKORE_ROOT) python -m uvicorn \
--factory skore.api:create_api_app \
--factory skore.ui.app:create_app \
--reload --reload-dir ./src \
--host 0.0.0.0 \
--port 22140 \
--timeout-graceful-shutdown 0

serve-dashboard:
serve-ui:
SKORE_ROOT=$(SKORE_ROOT) python -m uvicorn \
--factory skore.dashboard:create_dashboard_app \
--factory skore.ui.app:create_app \
--reload --reload-dir ./src \
--host 0.0.0.0 \
--port 22140 \
Expand All @@ -36,11 +36,11 @@ build-frontend:
cd frontend && npm install
cd frontend && npm run build
# empty app static folder
rm -rf src/skore/dashboard/static
cp -a frontend/dist/. src/skore/dashboard/static
rm -rf src/skore/ui/static
cp -a frontend/dist/. src/skore/ui/static
# build the sharing library
cd frontend && npm run build:lib
cp -a frontend/dist/. src/skore/dashboard/static
cp -a frontend/dist/. src/skore/ui/static
# clean up
rm -rf frontend/dist

Expand Down
66 changes: 36 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,64 @@
## Installation

For now, the only supported method to use skore is from source.
Follow the instructions in [CONTRIBUTING.md](/CONTRIBUTING.md#quick-start) to install dependencies and start the dashboard.
Follow the instructions in [CONTRIBUTING.md](/CONTRIBUTING.md#quick-start) to install dependencies and start the UI.

## Quick start

For a complete introductory example, see our [basic usage notebook](/notebooks/basic_usage.ipynb). The resulting skore dashboard has been exported to [this HTML file](https://gist.github.com/augustebaum/6b21dbd7f7d5a584fbf2c1956692574e): download it and open it in your browser to visualize it.
For a complete introductory example, see our [basic usage notebook](/notebooks/basic_usage.ipynb). The resulting skore report has been exported to [this HTML file](https://gist.github.com/augustebaum/6b21dbd7f7d5a584fbf2c1956692574e): download it and open it in your browser to visualize it.

Initialize and use a Store as follows:
In your shell, run the following to create a project file `project.skore` (the default) in your current working directory:
```sh
python -m skore create
```

Run the following in your Python code to load the project:
```python
from skore import Store
from skore import load

store = Store("root/probabl")
project = load("project.skore")
```

To initialize a Store, we need to give it a root path.
A store also needs some physical storage to get and put items from/into. By default, this storage will be in a `.datamander` directory in the current working directory. This can be customized by setting the MANDR_ROOT environment variable.
You can save items you need to track in your project:
```python
project.put("my int", 3)
```

You can also get them back:
```python
store.insert("my int", 3)
store.read("my int")
project.get("my int")
```

By default, strings are assumed to be Markdown:
```python
project.put("my string", "Hello world!")
```

# Strings are assumed to be Markdown:
store.insert("my string", "Hello world!")
store.update("my string", "Hello again!")
Note that `put` overwrites previous data
```python
project.put("my string", "Hello again!")
```

for key, value in store.items():
print(f"Key {key} corresponds to value {value}")
You can list all the keys in a project with:
```python
project.list_keys()
```

store.delete("my int")
You can delete items with:
```python
project.delete_item("my int")
```

Then, in your project root (i.e. where `.datamander` is), run the following command to start the frontend locally:
Then, in the directory containing your project, run the following command to start the UI locally:
```sh
python -m skore launch .datamander
python -m skore launch project.skore
```
This should automatically open a browser tab pointing at the app URL.

## Help for common issues

This will automatically open a browser at the UI's location.

### `make build-frontend` doesn't work!

Please check that your version of node is at least 20 using the following command: `node -v`

## Roadmap


With Skore, you can:
- Store data
- Visualize data
Expand All @@ -61,11 +72,6 @@ In the future, you will be able to:
- Extract insights from your data
- Get tips on how to improve your data science code

## Concepts

- A **Store** is the core concept of this project. It is a dict-like data structure that implements a CRUD interface.
- A **Storage** represents the actual data storage medium, e.g. a computer's filesystem or an S3 bucket. Every Store has one Storage.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for more information and to contribute to the evolution of this library.
See [CONTRIBUTING.md](/CONTRIBUTING.md) for more information and to contribute to the evolution of this library.
2 changes: 1 addition & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Dashboard
# Skore UI

This sub directory aims at creating a single page application supporting Skore.

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ShareApp.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import Simplebar from "simplebar-vue";
import DataStoreCanvas from "@/components/DataStoreCanvas.vue";
import ReportCanvas from "@/components/ReportCanvas.vue";
</script>

<template>
Expand All @@ -10,7 +10,7 @@ import DataStoreCanvas from "@/components/DataStoreCanvas.vue";
<h1>Report</h1>
</div>
<Simplebar class="canvas-wrapper">
<DataStoreCanvas :showCardButtons="false" />
<ReportCanvas :showCardButtons="false" />
</Simplebar>
</div>
</template>
Expand Down
138 changes: 0 additions & 138 deletions frontend/src/components/DataStoreCanvas.vue

This file was deleted.

58 changes: 0 additions & 58 deletions frontend/src/components/FileTree.vue

This file was deleted.

Loading

0 comments on commit 8c70941

Please sign in to comment.