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

Merge barebone-studio/develop-main to optinist/develop-main #643

Merged
merged 30 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ea1af91
adjust caiman dependencies
Apr 18, 2024
4765836
Merge pull request #342 from arayabrain/feature/adjust-caiman-depende…
ahadjiev Apr 22, 2024
6d0277f
Update docs about x86_64 installation
Jun 4, 2024
c93fa91
improve logger
Jun 6, 2024
e2f3db9
add rule name for each rules
Jun 7, 2024
7a8d082
add validation for node input data
Jun 7, 2024
c580332
refactor snakemake modules
Jun 7, 2024
9b0e3f1
Merge pull request #347 from arayabrain/feature/improve-logger
emuemuJP Jun 11, 2024
e9cf786
Merge pull request #348 from arayabrain/feature/improve-snakemake-runner
emuemuJP Jun 11, 2024
a37bf5e
improve workflow runner
Jun 13, 2024
dcc791d
improve workflow runner
Jun 13, 2024
6e4e207
refactor ACCEPT_FILE_EXT
Jun 13, 2024
a71045a
fix typo
Jun 13, 2024
2e157a0
fix typo
Jun 13, 2024
7b2fe11
Merge pull request #354 from arayabrain/feature/improve-workflow-runner
emuemuJP Jun 14, 2024
ef3bc35
modify poetry option on dockerfile
Jun 21, 2024
ddd1f09
modify poetry option on dockerfile
Jun 21, 2024
c434c55
update vscode settings (for prettier)
Jun 24, 2024
a8afd5b
update settings for multiuser mode
Jun 25, 2024
3af0e07
update docs for multiuser mode
Jun 25, 2024
56124c3
corrected grammar
Jun 25, 2024
49cec32
update multiuser mode setup docs
Jun 27, 2024
af8bc92
add ExptDataWriter
Jun 27, 2024
ad49e3f
Merge pull request #363 from arayabrain/feature/update-vscode-settings
emuemuJP Jun 27, 2024
b8b9938
Merge pull request #366 from arayabrain/feature/add_expt-data-writer
emuemuJP Jun 27, 2024
74d885b
corrected wording
Jun 28, 2024
91dcdb8
Fixed ExptDataWriter bug
Jun 28, 2024
f878c29
Merge pull request #369 from arayabrain/feature/add_expt-data-writer
itutu-tienday Jul 1, 2024
16eacd3
Merge pull request #364 from arayabrain/feature/update-multiuser-sett…
emuemuJP Jul 2, 2024
502f7d1
Merge pull request #345 from arayabrain/feature/docsExplainRosetta
itutu-tienday Jul 4, 2024
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
2 changes: 2 additions & 0 deletions .vscode/settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
}
},
"eslint.workingDirectories": ["frontend"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"flake8.args": ["--config=.flake8"],
// NOTE: Uncomment following line and fix "optinist_dev" to your conda env name
// "flake8.path": ["conda", "run", "-n", "optinist_dev", "python", "-m", "flake8"],
Expand Down
58 changes: 58 additions & 0 deletions docker-compose.dev.multiuser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: "3"

services:
db:
image: mysql:8.4
ports:
- "127.0.0.1:13306:3306"
env_file:
- studio/config/.env
volumes:
- db_data:/var/lib/mysql
environment:
TZ: Asia/Tokyo
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1"]
interval: 10s
timeout: 5s
retries: 3

studio-dev-be:
build:
context: .
dockerfile: studio/config/docker/Dockerfile.dev
working_dir: /app
volumes:
- .:/app
# optinist data outputs directories
- ../optinist-docker-volumes/.snakemake/:/app/.snakemake
- ../optinist-docker-volumes/logs/:/app/logs
- ../optinist-docker-volumes/studio_data/:/app/studio_data
ports:
- "127.0.0.1:8000:8000"
command: >
bash -c "
alembic upgrade head &&
poetry run python main.py --reload --host 0.0.0.0 --port 8000
"
environment:
PYTHONPATH: /app/
TZ: Asia/Tokyo
OPTINIST_DIR: /app/studio_data
depends_on:
db:
condition: service_healthy

studio-dev-fe:
image: node:20.8.0-alpine3.18
working_dir: /app/frontend
volumes:
- ./frontend/:/app/frontend/:cached
ports:
- "127.0.0.1:3000:3000"
command: ash -c 'yarn install && yarn start'
environment:
TZ: Asia/Tokyo

volumes:
db_data:
3 changes: 3 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ services:
working_dir: /app
volumes:
- .:/app
# optinist data outputs directories
- ../optinist-docker-volumes/.snakemake/:/app/.snakemake
- ../optinist-docker-volumes/logs/:/app/logs
- ../optinist-docker-volumes/studio_data/:/app/studio_data
ports:
- "127.0.0.1:8000:8000"
Expand Down
189 changes: 108 additions & 81 deletions docs/host_for_multiuser/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,28 @@ Follow the steps below to setup `multiuser` mode.
```
2. copy config files
```bash
cp studio/config/.env.example studio/config.env
cp studio/config/auth/firebase_config.example.json studio/config/auth/firebase_config.json
cp -i studio/config/.env.example studio/config/.env
cp -i studio/config/auth/firebase_config.example.json studio/config/auth/firebase_config.json
```

### Create your Firebase Project
### Setup Firebase Authentication

#### Create your Firebase Project
1. Go to [https://console.firebase.google.com/](https://console.firebase.google.com/)
2. Click "Add project".
3. Enter your project name, and click "Continue".
4. Google Analytics is optional. You can choose "Enable Google Analytics for this project" or not.
5. After your project is ready, click "Continue".

### Setup Firebase Authentication
#### Setup Firebase Authentication
1. Select "Build > Authentication" from the left menu.
2. Select "Get started".
3. Select "Sign-in method" tab.
4. Select "Add new provider" in "Sign-in providers" section.
5. Click "Email/Password" and enable it.
6. Click "Save".

### Create admin user for the project
#### Create admin user for the project
1. Select "Authentication" from the left menu.
2. Select "Users" tab.
3. Click "Add user" button.
Expand All @@ -45,7 +47,7 @@ Follow the steps below to setup `multiuser` mode.

- Created user's "User UID" is required later.

### Get Firebase tokens
#### Get Firebase tokens
1. Click setting icon(besides Project Overview), then select "Project settings" from the left menu.
2. Select "General" tab.
3. Select "web app" in "Your apps" section.
Expand All @@ -62,90 +64,115 @@ Follow the steps below to setup `multiuser` mode.
- (keep databaseURL blank)
7. Select "Service accounts" tab.
8. Click "Generate new private key" in "Firebase Admin SDK" section.
9. Put the downloaded file to `studio/config/auth/firebase_private.json`.

### Setup mysql(or mariadb)
1. Install mysql(or mariadb) server.
2. Connect mysql server.
9. Save the downloaded file to `studio/config/auth/firebase_private.json`.

### Setup Database
- Set up your own mysql (or mariadb) server or use docker compose mysql
- Below are the instructions for using mysql with docker compose.

1. Edit configs.
- Edit studio/config/.env
- Set `MYSQL_SERVER` to db server host or ip
- Format: `{DB_HOST}:{DB_PORT}`
- \*For docker platform, the fixed value `db:3306` is fine.
- Set `MYSQL_ROOT_PASSWORD` to database root password, which you have decided.
- Set `MYSQL_DATABASE` to `{YOUR_DATABASE_NAME}`, which you have decided.
- Set `MYSQL_USER` to `{DB_USER_NAME}`, which you have decided.
- Set `MYSQL_PASSWORD` to `{DB_USER_PASSWORD}`, which you have decided.
2. Install & run mysql server.
```bash
mysql -u root -p
```
3. Create database for your project.
```sql
CREATE DATABASE YOUR_DATABASE_NAME;
```
4. Create user for your project.
```sql
CREATE USER 'DB_USER_NAME'@'localhost' IDENTIFIED BY 'DB_USER_PASSWORD';
```
5. Grant all privileges to the user for the database.
```sql
GRANT ALL PRIVILEGES ON YOUR_DATABASE_NAME.* TO 'DB_USER_NAME'@'localhost';
docker compose -f docker-compose.dev.multiuser.yml up db -d
```

### Set OptiNiSt config
1. Edit `studio/config/.env`
- The database and db_user are automatically generated based on the .env settings.
3. Check connection to mysql server.
- Connecting via docker command
```bash
docker exec -it {DB_CONTAINER_NAME} mysql -u {DB_USER_NAME} -p {YOUR_DATABASE_NAME}
mysql> exit
```
- Note: `{DB_CONTAINER_NAME}` is the container name or container ID of the database docker container. (Can be confirmed with `docker ps`)
- Connect via mysql command (requires mysql-client)
```bash
mysql -h {DB_HOST} --port={DB_PORT} -u {DB_USER_NAME} -p {YOUR_DATABASE_NAME}
mysql> exit
```
- If a connection to the database server is available, the setup was successful.

### Setup & Run OptiNiSt

#### For Docker Platform

To use multiuser mode with Docker, perform the following steps.

##### Setup Backend

###### 1. Set OptiNiSt config
- Edit `studio/config/.env`
- Change `SECRET_KEY` to any random string.
- Change `USE_FIREBASE_TOKEN` to `True`.
- Change `IS_STANDALONE` to `False`
- Set `MYSQL_SERVER` to your host
- Set `MYSQL_DATABASE` to {YOUR_DATABASE_NAME}, which you created in the previous step.
- Set `MYSQL_USER` to {DB_USER_NAME}, which you created in the previous step.
- Set `MYSQL_PASSWORD` to {DB_USER_PASSWORD}, which you created in the previous step.
- `MYSQL_ROOT_PASSWORD` can be left commented.

### Setup Frontend
1. Install node.js(version 20)
- https://nodejs.org
2. Install yarn
```bash
npm install -g yarn
```
3. Install frontend requirements
```bash
cd frontend
yarn install
```
4. Build frontend
```bash
yarn build
```

### Setup Backend
- See OptiNiSt installation guide.
- After create and activate conda environment for the project, run following commands
###### 2. Start backend (Database is set up on startup)
```bash
docker compose -f docker-compose.dev.multiuser.yml up studio-dev-be -d
```

1. Install backend requirements
```bash
cd studio
pip install .
```
2. Setup database
```bash
alembic upgrade head
```
3. Insert initial data
###### 3. Insert initial data
```bash
docker exec -it {DB_CONTAINER_NAME} mysql -u {DB_USER_NAME} -p {YOUR_DATABASE_NAME}
```
```sql
INSERT INTO organization (name) VALUES ('{YOUR_ORGANIZATION_NAME}');
INSERT INTO roles (id, role) VALUES (1, 'admin'), (20, 'operator');
INSERT INTO users (uid, organization_id, name, email, active) VALUES ('{FIREBASE_USER_UID}', 1, '{YOUR_NAME}', '{YOUR_EMAIL}', true);
INSERT INTO user_roles (user_id, role_id) VALUES (1, 1);
```
- Note on Variables
- `{FIREBASE_USER_UID}` ... The user uid you created in the previous step ([Create admin user for the project](#create-admin-user-for-the-project)).
- `{YOUR_ORGANIZATION_NAME}` ... Display name on system (Any text)
- `{YOUR_NAME}` ... Display name on system (Any text)
- `{YOUR_EMAIL}` ... Email address corresponding to `{FIREBASE_USER_UID}`

- About Roles
- Only 2 roles, "admin" and "operator" are supported for now.
- "admin"
- can manage other users
- "operator"
- general user
- More information is [here](usage.md).

##### Run OptiNiSt
```bash
docker compose -f docker-compose.dev.multiuser.yml up -d
```

```bash
mysql -u DB_USER_NAME -p
```
```sql
USE YOUR_DATABASE_NAME;
INSERT INTO organization (name) VALUES ('YOUR_ORGANIZATION_NAME');
INSERT INTO roles (id, role) VALUES (1, 'admin'), (20, 'operator');
INSERT INTO users (uid, organization_id, name, email, active, ) VALUES ('USER_UID', 1, 'YOUR_EMAIL', 'YOUR_PASSWORD', 1);
INSERT INTO user_roles (user_id, role_id) VALUES (1, 1);
```
- USER_UID is the user uid you created in the previous step ([Create admin user for the project](#create-admin-user-for-the-project)).
- Only 2 roles, "admin" and "operator" are supported for now.
- "admin"
- can manage other users
- "operator"
- general user

### Run OptiNiSt
1. Access to `http://{YOUR_HOST}:8000` from your browser.
2. Confirm that you can SingIn with your Firebase Authentication account.

#### For Non-Docker Platforms

Below are the steps for a case using Non-Docker platforms (Windows, Mac, Linux).

##### Setup Backend
- See [OptiNiSt installation guide](../installation/index.rst).
- After creating and activating a conda environment for the project, run following commands

###### 1. Set OptiNiSt config
- Same as [Set OptiNiSt config](#set-optinist-config) procedure.

###### 2. Setup database
```bash
cd {OPTINIST_ROOT_PATH} # root path of repository cloned
alembic upgrade head
```

###### 3. Insert initial data
- Same as [Insert initial data](#insert-initial-data) procedure.

##### Run OptiNiSt
```bash
python main.py
```

- Access to `http://{YOUR_HOST}:8000` from your browser.
1. Access to `http://{YOUR_HOST}:8000` from your browser.
2. Confirm that you can SingIn with your Firebase Authentication account.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ Main Features
gui/index
host_for_multiuser/index
utils/index
utils/nwb_file
for_developers/index
6 changes: 6 additions & 0 deletions docs/installation/docker_for_developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ git clone https://github.com/oist/optinist.git
cd ./optinist
```

- copy config files
```
cp studio/config/.env.example studio/config/.env
cp frontend/.env.example frontend/.env
```

### Start docker container

```
Expand Down
8 changes: 7 additions & 1 deletion docs/installation/each_platforms_for_developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Get node with version 20
You can also install node via [nvm](https://github.com/nvm-sh/nvm)

After install node, install yarn.
```bash
```
npm install -g yarn
```

Expand All @@ -45,6 +45,12 @@ git clone https://github.com/oist/optinist.git
cd ./optinist
```

- copy config files
```
cp studio/config/.env.example studio/config/.env
cp frontend/.env.example frontend/.env
```

### Create anaconda environment

```
Expand Down
Loading
Loading