Skip to content

Commit e8c5985

Browse files
authored
Merge pull request #38 from NREL/dash-js
Move dashboard app to JavaScript
2 parents 66938e4 + f23a6b7 commit e8c5985

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+15417
-526
lines changed

Cargo.toml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ members = [
33
".",
44
"torc-server",
55
"torc-slurm-job-runner",
6-
7-
6+
"torc-dash",
87
]
98
resolver = "2"
109

@@ -18,6 +17,11 @@ edition = "2024"
1817
# Shared dependencies
1918
serde = { version = "1.0", features = ["derive"] }
2019
serde_json = "1.0"
20+
21+
# Configuration management
22+
config = { version = "0.14", features = ["toml"] }
23+
dirs = "5"
24+
toml = "0.8"
2125
serde_repr = "0.1"
2226
serde_with = { version = "3.8", default-features = false, features = ["base64", "std", "macros"] }
2327
chrono = { version = "0.4", features = ["serde"] }
@@ -50,7 +54,12 @@ petgraph = "0.6"
5054
plotly = { version = "0.10", default-features = false, features = ["kaleido"] }
5155

5256
# Server-specific
57+
rust-embed = "8.5"
5358
async-trait = "0.1.24"
59+
axum = { version = "0.7", features = ["tokio", "http1", "http2"] }
60+
tower = "0.4"
61+
tower-http = { version = "0.5", features = ["cors", "fs"] }
62+
mime_guess = "2.0"
5463
swagger = { version = "6.1", features = ["serdejson", "server", "client", "tls", "tcp"] }
5564
hyper = { version = "0.14", features = ["full"] }
5665
serde_ignored = "0.1.1"
@@ -107,6 +116,11 @@ required-features = ["client", "tui", "plot_resources", "cli-docs"]
107116

108117
[features]
109118
default = ["client", "tui", "plot_resources"]
119+
config = [
120+
"dep:config",
121+
"dep:dirs",
122+
"dep:toml",
123+
]
110124
server = [
111125
"dep:async-trait",
112126
"dep:swagger",
@@ -123,6 +137,7 @@ server = [
123137
"dep:sha2",
124138
"dep:tracing",
125139
"dep:bcrypt",
140+
"dep:rust-embed",
126141
]
127142
client = [
128143
"dep:reqwest",
@@ -144,6 +159,7 @@ client = [
144159
"dep:signal-hook",
145160
"dep:libc",
146161
"dep:nvml-wrapper",
162+
"config",
147163
]
148164
tui = [
149165
"client",
@@ -194,6 +210,7 @@ jsonwebtoken = { workspace = true, optional = true }
194210
sha2 = { workspace = true, optional = true }
195211
tracing = { workspace = true, optional = true }
196212
bcrypt = { workspace = true, optional = true }
213+
rust-embed = { workspace = true, optional = true }
197214

198215
# Client dependencies (optional)
199216
reqwest = { workspace = true, optional = true }
@@ -223,6 +240,11 @@ petgraph = { workspace = true, optional = true }
223240
# Plot-resources dependencies (optional)
224241
plotly = { workspace = true, optional = true }
225242

243+
# Configuration management
244+
config = { workspace = true, optional = true }
245+
dirs = { workspace = true, optional = true }
246+
toml = { workspace = true, optional = true }
247+
226248
# Conversion feature dependencies
227249
frunk = { version = "0.4.0", optional = true }
228250
frunk_derives = { version = "0.4.0", optional = true }
@@ -248,6 +270,7 @@ tempfile = "3.22.0"
248270
serial_test = "3.0"
249271
reqwest = { workspace = true }
250272
clap-markdown = "0.1"
273+
libc = "0.2"
251274

252275
# CLI documentation generator depends on clap-markdown
253276
# It's also in dev-dependencies for tests

docs/src/SUMMARY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# How-To Guides
2929

3030
- [How-To](./how-to/README.md)
31+
- [Configuration Files](./how-to/configuration-files.md)
3132
- [Creating Workflows](./how-to/creating-workflows.md)
3233
- [Working with Slurm](./how-to/slurm.md)
3334
- [Job Checkpointing](./how-to/checkpointing.md)
@@ -53,6 +54,9 @@
5354
# Tutorials
5455

5556
- [Tutorials](./tutorials/README.md)
57+
- [Configuration Files](./tutorials/configuration.md)
58+
- [Dashboard Deployment](./tutorials/dashboard-deployment.md)
59+
- [Workflow Wizard](./tutorials/workflow-wizard.md)
5660
- [Many Independent Jobs](./tutorials/many-jobs.md)
5761
- [Diamond Workflow](./tutorials/diamond.md)
5862
- [User Data Dependencies](./tutorials/user-data.md)

docs/src/how-to/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This section provides task-oriented guides for accomplishing specific goals with
44

55
**Topics covered:**
66

7+
- [Configuration Files](./configuration-files.md) - Setting up and using configuration files
78
- [Creating Workflows](./creating-workflows.md) - Different methods for creating workflows
89
- [Working with Slurm](./slurm.md) - Running workflows on Slurm clusters
910
- [Job Checkpointing](./checkpointing.md) - Saving progress during wall-time timeouts
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# Using Configuration Files
2+
3+
This guide shows how to set up and use configuration files for Torc components.
4+
5+
## Quick Start
6+
7+
Create a user configuration file:
8+
9+
```bash
10+
torc config init --user
11+
```
12+
13+
Edit the file at `~/.config/torc/config.toml` to set your defaults.
14+
15+
## Configuration File Locations
16+
17+
| Location | Purpose | Priority |
18+
|----------|---------|----------|
19+
| `/etc/torc/config.toml` | System-wide defaults | 1 (lowest) |
20+
| `~/.config/torc/config.toml` | User preferences | 2 |
21+
| `./torc.toml` | Project-specific | 3 |
22+
| Environment variables | Runtime overrides | 4 |
23+
| CLI arguments | Explicit overrides | 5 (highest) |
24+
25+
## Available Commands
26+
27+
```bash
28+
# Show configuration file locations
29+
torc config paths
30+
31+
# Show effective (merged) configuration
32+
torc config show
33+
34+
# Show as JSON
35+
torc config show --format json
36+
37+
# Create configuration file
38+
torc config init --user # User config
39+
torc config init --local # Project config
40+
torc config init --system # System config (requires root)
41+
42+
# Validate configuration
43+
torc config validate
44+
```
45+
46+
## Client Configuration
47+
48+
Common client settings:
49+
50+
```toml
51+
[client]
52+
api_url = "http://localhost:8080/torc-service/v1"
53+
format = "table" # or "json"
54+
log_level = "info"
55+
username = "myuser"
56+
57+
[client.run]
58+
poll_interval = 5.0
59+
output_dir = "output"
60+
max_parallel_jobs = 4
61+
num_cpus = 8
62+
memory_gb = 32.0
63+
num_gpus = 1
64+
```
65+
66+
## Server Configuration
67+
68+
For `torc-server`:
69+
70+
```toml
71+
[server]
72+
url = "0.0.0.0"
73+
port = 8080
74+
threads = 4
75+
database = "/path/to/torc.db"
76+
auth_file = "/path/to/htpasswd"
77+
require_auth = false
78+
completion_check_interval_secs = 60.0
79+
log_level = "info"
80+
https = false
81+
82+
[server.logging]
83+
log_dir = "/var/log/torc"
84+
json_logs = false
85+
```
86+
87+
## Dashboard Configuration
88+
89+
For `torc-dash`:
90+
91+
```toml
92+
[dash]
93+
host = "127.0.0.1"
94+
port = 8090
95+
api_url = "http://localhost:8080/torc-service/v1"
96+
torc_bin = "torc"
97+
torc_server_bin = "torc-server"
98+
standalone = false
99+
server_port = 0
100+
completion_check_interval_secs = 5
101+
```
102+
103+
## Environment Variables
104+
105+
Use environment variables for runtime configuration. Use double underscore (`__`) to separate nested keys:
106+
107+
```bash
108+
# Client settings
109+
export TORC_CLIENT__API_URL="http://server:8080/torc-service/v1"
110+
export TORC_CLIENT__FORMAT="json"
111+
112+
# Server settings
113+
export TORC_SERVER__PORT="9999"
114+
export TORC_SERVER__THREADS="8"
115+
116+
# Dashboard settings
117+
export TORC_DASH__PORT="8090"
118+
```
119+
120+
## Overriding with CLI Arguments
121+
122+
CLI arguments always take precedence:
123+
124+
```bash
125+
# Uses config file for api_url, but CLI for format
126+
torc --format json workflows list
127+
128+
# CLI url overrides config file
129+
torc --url http://other:8080/torc-service/v1 workflows list
130+
```
131+
132+
## Common Patterns
133+
134+
### Development Environment
135+
136+
```toml
137+
# ~/.config/torc/config.toml
138+
[client]
139+
api_url = "http://localhost:8080/torc-service/v1"
140+
log_level = "debug"
141+
142+
[client.run]
143+
poll_interval = 2.0
144+
```
145+
146+
### Team Shared Server
147+
148+
```toml
149+
# ~/.config/torc/config.toml
150+
[client]
151+
api_url = "http://torc.internal.company.com:8080/torc-service/v1"
152+
username = "developer"
153+
```
154+
155+
### CI/CD Pipeline
156+
157+
```bash
158+
#!/bin/bash
159+
export TORC_CLIENT__API_URL="${CI_TORC_SERVER}"
160+
export TORC_CLIENT__FORMAT="json"
161+
162+
torc run workflow.yaml
163+
result=$(torc workflows status $WORKFLOW_ID | jq -r '.status')
164+
```
165+
166+
### HPC Cluster
167+
168+
```toml
169+
# Project-local torc.toml
170+
[client]
171+
api_url = "http://login-node:8080/torc-service/v1"
172+
173+
[client.run]
174+
num_cpus = 64
175+
memory_gb = 256.0
176+
num_gpus = 8
177+
output_dir = "/scratch/user/workflow_output"
178+
```
179+
180+
## Troubleshooting
181+
182+
**Configuration not applied?**
183+
184+
1. Check which files are loaded: `torc config validate`
185+
2. View effective config: `torc config show`
186+
3. Verify file permissions and syntax
187+
188+
**Environment variable not working?**
189+
190+
Use double underscore for nesting: `TORC_CLIENT__API_URL` (not `TORC_CLIENT_API_URL`)
191+
192+
**Invalid configuration?**
193+
194+
Run validation: `torc config validate`

0 commit comments

Comments
 (0)