Skip to content

Commit

Permalink
Merge pull request #2 from antonko/rc
Browse files Browse the repository at this point in the history
Bulk update with minor improvements and corrections
  • Loading branch information
antonko authored Apr 2, 2024
2 parents dbc2429 + 9095ac2 commit d5276be
Show file tree
Hide file tree
Showing 28 changed files with 1,133 additions and 6,006 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Auto detect text files and perform LF normalization
* text=lf
*.js linguist-detect=false
*.js linguist-detect=false
.vscode/*.json linguist-language=JSON-with-Comments
*.cjs linguist-vendored
54 changes: 0 additions & 54 deletions .github/workflows/commit.yml

This file was deleted.

27 changes: 15 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code Check on Release

on:
push:
branches: [main]
branches: [main, rc]

jobs:
frontend-check:
Expand Down Expand Up @@ -99,27 +99,30 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build Docker image
run: docker build -t antonk0/arq-ui:latest .

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-archive
path: ./

- name: Install semantic release
uses: actions/setup-node@v4
with:
node-version: "20"


- name: Install dependencies
run: npm ci

- name: Release
run: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
49 changes: 48 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,56 @@ name: Code Check on Push

on:
pull_request:
branches: [main]
branches: [main, rc]

jobs:
frontend-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Enable Corepack
run: corepack enable

- name: Install Yarn 2
run: yarn set version berry
working-directory: ./frontend

- name: Install dependencies
run: yarn install
working-directory: ./frontend

- name: Run linter
run: yarn run lint
working-directory: ./frontend

- name: Build
run: yarn run build
working-directory: ./frontend

backend-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PDM
uses: pdm-project/setup-pdm@v4

- name: Install dependencies
working-directory: ./backend
run: pdm install --dev

- name: Run linter
working-directory: ./backend
run: pdm run ruff .

docker-build:
runs-on: ubuntu-latest

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
/node_modules

21 changes: 18 additions & 3 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"branches": [
"main"
"main",
{
"name": "rc",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
Expand All @@ -18,9 +22,20 @@
}
],
[
"@semantic-release-plus/docker",
"@codedependant/semantic-release-docker",
{
"name": "antonk0/arq-ui"
"dockerTags": [
"{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
"{{major}}-{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
"{{major}}.{{minor}}-{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
"{{version}}"
],
"dockerImage": "arq-ui",
"dockerProject": "antonk0",
"dockerPlatform": [
"linux/amd64",
"linux/arm64"
]
}
]
]
Expand Down
90 changes: 89 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,93 @@
# arq-ui
View and manage tasks running through arq

This project is a simple interface for monitoring jobs executed using the [arq](https://github.com/samuelcolvin/arq) library.

![arq UI](./docs/screenshot1.png)

## Features

- Providing statistics on job statuses: total number, number of jobs in queue, jobs being executed, and jobs with errors.
- Visualization of jobs distribution over time in the form of a timeline.
- Displaying a list of jobs with filtering, searching, and sorting capabilities.
- Ability to abort jobs.

## Limitations

- The interface reads data directly from Redis, not storing the state of jobs, which allows tracking tasks only for the last hour. There are plans to add functionality for permanent data storage.
- `arq` uses the `pickle` library for data serialization, which limits the ability to deserialize objects of custom classes that are not accessible. If `arq-ui` cannot deserialize the data, tasks with such data will not be displayed in the monitoring.
- To enable job cancellation, the worker must be configured with the `allow_abort_jobs` parameter.
- Handling a large number of jobs (more than 50,000) may decrease the application's performance.
- The interface does not have built-in security features, therefore it is not recommended to be exposed to the public without additional security measures.


## Demo

[https://demo.arq-ui.florm.io/arq/ui/](https://demo.arq-ui.florm.io/arq/ui/)

## Installation and Launch

### Using Docker

To launch:

```bash
docker pull antonk0/arq-ui
docker run -p 8000:8000 -e REDIS_HOST=redis.host.com -e REDIS_PORT=6379 antonk0/arq-ui
```

docker-compose.yml

```yaml
version: '3'
services:
arq-ui:
image: antonk0/arq-ui:latest
restart: unless-stopped
environment:
- REDIS_HOST=redis.host.com
- REDIS_PASSWORD=your_password
- REDIS_PORT=6379
- REDIS_SSL=False
- REDIS_DB=0
ports:
- 8000:8000
```
### Running from Source
Download the latest stable release from the GitHub releases, unzip it, and execute the following commands:
```bash
pdm install
cd src
pdm run uvicorn main:app --host=0.0.0.0 --port=8000
```

If `pdm` is not installed, you can install it using `pip`:

```bash
pip install pdm
```

## Configuration

The interface is accessible at `/arq/ui/`. Swagger API documentation is available at `/arq/api/docs/`.

Possible environment variables:

| Variable | Description | Default Value |
| -------- | ----------- | ------------- |
| `REDIS_HOST` | Address of the Redis server | `redis` |
| `REDIS_PORT` | Port of the Redis server | `6379` |
| `REDIS_PASSWORD` | Password for connecting to Redis | `""` (no password) |
| `REDIS_SSL` | Whether to use SSL for connecting to Redis | `False` |
| `REDIS_DB` | Redis database number | `0` |
| `MAX_JOBS` | Maximum number of tasks that can be displayed in the interface | `50000` |
| `REQUEST_SEMAPHORE_JOBS` | Number of tasks that can be requested simultaneously | `5` |
| `QUEUE_NAME` | Name of the queue in Redis | `arq:queue` |

## Development


```
docker compose -f docker-compose.dev.yml build
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Settings(BaseSettings):

max_jobs: int = 50000
request_semaphore_jobs: int = 5
queue_name: str = "arq:queue"

model_config = SettingsConfigDict(env_file=os.getenv("ENV_FILE", ".env"))

Expand Down
14 changes: 4 additions & 10 deletions backend/src/endpoints/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,8 @@ async def get_hourly_statistics() -> list[JobsTimeStatistics]:
)
async def create_job(new_job: JobCreate) -> Job:
"""Create job."""
job_service = JobService(
get_redis_settings(),
get_lru_cache(),
)
job = await job_service.create_job(new_job)
if not job:
raise HTTPException(
status_code=500,
detail="Failed to create a job.",
logger.info(f"Creating job with function {new_job.function}.")
raise HTTPException(
status_code=501,
detail="Not implemented",
)
return job
Loading

0 comments on commit d5276be

Please sign in to comment.