Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
205 changes: 83 additions & 122 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,171 +1,132 @@
# How to setup
## 1. Clone this repository
# LabCode

Clone this repository with following command:
自動実験プロトコル言語プラットフォーム

```bash
git clone git@github.com:fuku-inc/labcode-test-environment.git
```

## 2. Clone service repositories
## クイックスタート

Move into `labcode-test-environment` directory, run
### 1. リポジトリのクローン

```bash
bash clone_repositories.sh
git clone --recurse-submodules <repository-url>
cd labcode-test-environment
```

Then, these repository is cloned:

1. `labcode-sim`
2. `labcode-log-server`
3. `labcode-web-app`

## 3. Edit environmental variables

Copy template file with following command:

```bash
cp labcode-web-app/app/.env.example labcode-web-app/app/.env
```

Then, edit `labcode-web-app/app/.env` and replace `your-google-client-id.apps.googleusercontent.com` with correct client ID.

## 4. Build containers
### 2. ビルド & 起動

```bash
docker compose build
```

## 5. Run containers

```bash
docker compose up -d
```

## 6. (Only first time) setup database
### 3. 初回ユーザー作成

```bash
docker compose exec log_server sh -c "python -m define_db.models"
curl -X POST "http://localhost:8000/api/users/" -d "email=your-email@example.com"
```

## 7. Create user
### 4. アクセス

1. Access to http://localhost:8000/docs#/users/create_users__post
2. Click "Try it out"
3. Enter email address to "email"
4. Click "Execute"
5. You will obtain response as follows:
```
{
"id": 1,
"email": "example@gmail.com"
}
```
6. Memo the value of "id" as user ID

## 8. Create Project

1. Access to http://localhost:8000/docs#/projects/create_projects__post
2. Click "Try it out"
3. Enter project name to "name"
4. Enter user ID obtained at user creation to "user_id"
5. Click "Execute"
6. You will obtain response as follows:

```{
"id": 1,
"name": "test_project",
"user_id": 1,
"created_at": "2025-02-25T10:44:18.911007",
"updated_at": "2025-02-25T10:44:18.911017"
}
```
6. Memo the value of "id" as project ID.
| サービス | URL |
|---------|-----|
| Web UI | http://localhost:5173 |
| Admin Panel | http://localhost:5173/admin |
| API (Swagger UI) | http://localhost:8000/docs |

## 9. Run experiment
---

1. Access to http://0.0.0.0:8080/docs#/default/run_experiment_run_experiment_post
2. Click "Try it out"
3. Enter project ID obtained at project creation to "project_id"
4. Enter protocol name to "protocol_name"
5. Enter user ID obtained at user creation to "user_id"
6. Upload `labcode-test-environment/protocol.yaml` to "protocol_yaml"
7. Upload `labcode-test-environment/manipulate.yaml` to "manipulate_yaml"
5. Click "Execute"
## ドキュメント

## 10. Access to Experiment tracking UI
詳細なドキュメントは [docs/](./docs/) フォルダを参照してください。

Access to http://localhost:5173/
| ドキュメント | 説明 |
|-------------|------|
| [クイックスタート](./docs/00_quickstart.md) | 詳細なセットアップ手順 |
| [システムアーキテクチャ](./docs/01_architecture.md) | システム構成 |
| [Admin Panel](./docs/02_admin_panel.md) | 管理画面の機能 |
| [API リファレンス](./docs/03_api_reference.md) | API エンドポイント一覧 |
| [アップグレードガイド](./docs/04_migration_guide.md) | 既存環境からのアップグレード |
| [S3ストレージ設定](./docs/05_s3_storage_setup.md) | AWS S3連携設定 |
| [DB自動初期化](./docs/06_db_auto_initialization.md) | データベース初期化の仕組み |
| [リモートアクセス](./docs/07_remote_access.md) | 他PCからのアクセス設定 |

# How to access from another computer on the same network
---

## 1. Get the IP address of the computer running Experiment tracking ui
## アーキテクチャ

1. Open a terminal
2. Run the following command:
```mermaid
graph TB
subgraph Docker["labcode-test-environment"]
subgraph Frontend["Web UI"]
WebApp["labcode-web-app<br/>React + Vite<br/>Port: 5173"]
end

```bash
ip addr
```
subgraph Backend["Backend API"]
LogServer["labcode-log-server<br/>FastAPI + SQLite<br/>Port: 8000"]
end

Find the LAN IP address from the output:
subgraph Simulator["Simulator"]
Sim["labcode-sim<br/>Port: 8888"]
end

(example)
subgraph Storage["Storage"]
DB[(SQLite<br/>Database)]
S3[(AWS S3<br/>Optional)]
end
end

WebApp <--> LogServer
LogServer <--> Sim
LogServer --> DB
LogServer --> S3
Sim --> S3
```
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:1a:2b:3c:4d:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.5/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
valid_lft 86386sec preferred_lft 86386sec
```
In this example, 192.168.1.5 assigned to the eth0 (wired LAN) interface is the IP address within the LAN.
Look for an IP address with these characteristics:

Usually in the format of 192.168.xxx.xxx, 10.xxx.xxx.xxx, or 172.16.xxx.xxx to 172.31.xxx.xxx
Associated with eth0, eno1, enp0s3 (wired LAN) or wlan0, wlp2s0 (wireless LAN)
Displayed with scope global
---

## 2. Edit the hosts file on the computer you're using to access the Experiment tracking ui
## コンテナ操作

### Linux

#### 1. Edit the hosts file with root or sudo privilleges
```bash
# 停止
docker compose down

```
sudo nano /etc/hosts
```
# 再起動
docker compose restart

#### 2. Add the hostname and IP address
# ログ確認
docker compose logs -f

```
192.168.1.5 labcode-web-app.com
# 再ビルド
docker compose build --no-cache
docker compose up -d
```

(Replace 192.168.1.5 with the actual IP address of the web app server from the previous step)
---

### Windows
## トラブルシューティング

#### 1. Open Notepad with administrator privileges
### 「Internal Error」が表示される

Search for "Notepad" from the Start menu
Right-click on it and select "Run as administrator"
ユーザーが作成されていない可能性があります。初回ユーザー作成を実行してください。

```bash
curl -X POST "http://localhost:8000/api/users/" -d "email=your-email@example.com"
```

#### 2. Open `C:\Windows\System32\drivers\etc\hosts`
### コンテナが起動しない

#### 3. Add the hostname and IP address
```bash
# ログを確認
docker compose logs log_server

```
192.168.1.5 labcode-web-app.com
# 再ビルド
docker compose build --no-cache
docker compose up -d
```

(Replace 192.168.1.5 with the actual IP address of the web app server from the previous step)
詳細は [docs/00_quickstart.md](./docs/00_quickstart.md) のトラブルシューティングセクションを参照してください。

---

## 3. Access to Expeirment tracking ui
## ライセンス

Access to http://labcode-web-app.com:5173
[LICENSE](./LICENSE) を参照してください。
45 changes: 45 additions & 0 deletions compose.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ローカルストレージモード用 Docker Compose設定
services:
lab_simulator:
build: ./labcode-sim/lab_server
container_name: labcode_lab_simulator
volumes:
- ./labcode-sim/lab_server:/app
- ./labcode-sim/storage:/storage
- local_storage:/data/storage
ports:
- "8080:8080"
env_file:
- ./labcode-log-server/.env.local
networks:
- labcode_network
log_server:
build: ./labcode-log-server
container_name: labcode_log_server
ports:
- "8000:8000"
volumes:
- ./labcode-log-server/app:/app
- ./labcode-log-server/data:/data
- local_storage:/data/storage
env_file:
- ./labcode-log-server/.env.local
command: |
uvicorn main:app --host 0.0.0.0 --reload
networks:
- labcode_network
webapp:
build: ./labcode-web-app
container_name: labcode_experiment_tracking_ui
ports:
- "5173:5173"
networks:
- labcode_network

networks:
labcode_network:
driver: bridge

volumes:
local_storage:
driver: local
4 changes: 4 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ services:
- ./labcode-sim/storage:/storage
ports:
- "8080:8080"
env_file:
- ./labcode-log-server/.env
networks:
- labcode_network
log_server:
Expand All @@ -17,6 +19,8 @@ services:
volumes:
- ./labcode-log-server/app:/app
- ./labcode-log-server/data:/data
env_file:
- ./labcode-log-server/.env
command: |
uvicorn main:app --host 0.0.0.0 --reload
networks:
Expand Down
Loading