Automated tool that fetches anime data from AniList GraphQL API & uploads it to Kaggle as a dataset.
1.1K
This document provides instructions for running the AniList Anime Dataset Collector using Docker with Ofelia for scheduling.
Before running the container, you need to set up your Kaggle API credentials:
kaggle.json file containing your API credentials~/.kaggle/kaggle.json (Linux/Mac)C:\Users\<Windows-username>\.kaggle\kaggle.json (Windows)KAGGLE_JSON_PATH environment variableOfelia is a Docker job scheduler that can run commands, scripts, or Docker containers on a schedule. It's designed specifically for Docker environments and avoids the limitations of using cron inside containers.
Create a docker-compose.yml file with the following content:
services:
anilist-data-collector:
image: kdidtech/anilist-data-collector:latest
container_name: anilist-data-collector
volumes:
# Mount kaggle.json credentials file
- ~/.kaggle/kaggle.json:/root/.kaggle/kaggle.json:ro
# Optional: Mount a local directory to persist data between runs
- ./anime_data:/app/data
environment:
# Set timezone to CST (America/Chicago)
- TZ=America/Chicago
restart: unless-stopped
scheduler:
image: mcuadros/ofelia:latest
container_name: anime-data-collection-scheduler
command: daemon --docker
depends_on:
- anilist-data-collector
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
# Set the same timezone as the data collector
- TZ=America/Chicago
restart: unless-stopped
labels:
# Schedule the job to run every Sunday at 2am CST
# Ofelia uses 6-field cron format: seconds minutes hours day-of-month month day-of-week
ofelia.job-exec.anime-data-collection-job.schedule: "0 0 2 * * 0"
ofelia.job-exec.anime-data-collection-job.command: "/opt/venv/bin/python /app/main.py"
ofelia.job-exec.anime-data-collection-job.container: "anilist-data-collector"
Run the following command to start both the data collector and scheduler containers:
docker-compose up -d
This will:
Ofelia supports different job types. In our configuration, we use:
ofelia.job-exec.anime-data-collection-job.schedule: "0 0 2 * * 0"
ofelia.job-exec.anime-data-collection-job.command: "/opt/venv/bin/python /app/main.py"
ofelia.job-exec.anime-data-collection-job.container: "anilist-data-collector"
Ofelia uses a 6-field cron syntax for scheduling, which includes seconds:
seconds minutes hours day-of-month month day-of-week
Examples:
0 0 2 * * 0 - Every Sunday at 2:00:00 AM (0 seconds, 0 minutes, 2 hours, any day of month, any month, Sunday)0 0 4 * * 1 - Every Monday at 4:00:00 AM0 0 0 1 * * - First day of every month at midnight0 0 12 * * 1-5 - Every weekday at noonOfelia also supports interval notation:
@every 1h30m - Every 1 hour and 30 minutes@every 1h - Every hour@daily - Once a dayTo change when the job runs, modify the ofelia.job-exec.anime-data-collection-job.schedule label in the docker-compose.yml file, remembering to use the 6-field format.
To pass command-line arguments to the script, modify the command in the job-exec label:
# Run in test mode
ofelia.job-exec.anime-data-collection-job.command: "/opt/venv/bin/python /app/main.py --test"
# Skip data fetching
ofelia.job-exec.anime-data-collection-job.command: "/opt/venv/bin/python /app/main.py --skip-fetch"
# Skip Kaggle upload
ofelia.job-exec.anime-data-collection-job.command: "/opt/venv/bin/python /app/main.py --skip-upload"
To see the scheduler logs and job execution status:
docker logs anime-data-collection-scheduler
To see the logs from the data collector when it runs:
docker logs anilist-data-collector
Ofelia provides a simple HTTP API to check job status. By default, it listens on port 8080:
# Add this to the scheduler service in docker-compose.yml
ports:
- "8080:8080"
Then access http://localhost:8080/jobs to see the status of all jobs.
If Ofelia is not running the scheduled jobs:
Check if Ofelia has access to the Docker socket:
docker exec -it anime-data-collection-scheduler ls -la /var/run/docker.sock
Verify the container names match exactly:
docker ps
Check Ofelia logs for errors:
docker logs anime-data-collection-scheduler
Verify the cron format is correct (remember Ofelia uses 6 fields):
seconds minutes hours day-of-month month day-of-week
If the data collector job fails:
Run the container manually to see the error:
docker run --rm \
-v ~/.kaggle/kaggle.json:/root/.kaggle/kaggle.json:ro \
kdidtech/anilist-data-collector:latest
Check if the Kaggle credentials are mounted correctly:
docker exec -it anilist-data-collector ls -la /root/.kaggle
Verify the data directory permissions:
docker exec -it anilist-data-collector ls -la /app/data
You can pass environment variables to the data collector:
anilist-data-collector:
image: kdidtech/anilist-data-collector:latest
container_name: anilist-data-collector
volumes:
- ~/.kaggle/kaggle.json:/root/.kaggle/kaggle.json:ro
environment:
- TZ=America/Chicago
- LOG_LEVEL=DEBUG
You can configure multiple jobs with different schedules:
labels:
# Weekly full run
ofelia.job-exec.weekly-job.schedule: "0 0 2 * * 0"
ofelia.job-exec.weekly-job.command: "/opt/venv/bin/python /app/main.py"
ofelia.job-exec.weekly-job.container: "anilist-data-collector"
# Daily test run
ofelia.job-exec.daily-test.schedule: "0 0 4 * * *"
ofelia.job-exec.daily-test.command: "/opt/venv/bin/python /app/main.py --test"
ofelia.job-exec.daily-test.container: "anilist-data-collector"
Ofelia supports email notifications for job execution:
scheduler:
image: mcuadros/ofelia:latest
command: daemon --docker
environment:
- OFELIA_SMTP_HOST=smtp.example.com
- OFELIA_SMTP_PORT=587
- OFELIA_SMTP_USER=user
- OFELIA_SMTP_PASSWORD=password
- [email protected]
labels:
ofelia.job-exec.anime-data-collection-job.schedule: "0 0 2 * * 0"
ofelia.job-exec.anime-data-collection-job.command: "/opt/venv/bin/python /app/main.py"
ofelia.job-exec.anime-data-collection-job.container: "anilist-data-collector"
ofelia.job-exec.anime-data-collection-job.email-on-error: "[email protected]"
Content type
Image
Digest
sha256:c9d90b611…
Size
89.9 MB
Last updated
over 1 year ago
docker pull kdidtech/anilist-data-collector