|
| 1 | +# RO-Crate Validation Service |
| 2 | + |
| 3 | +This project presents a Flask-based API for validating RO-Crates. |
| 4 | + |
| 5 | +## Project Structure |
| 6 | + |
| 7 | +``` |
| 8 | +app/ |
| 9 | +├── ro_crates/ |
| 10 | +│ ├── routes/ |
| 11 | +│ │ ├── __init__.py # Registers blueprints |
| 12 | +│ │ └── post_routes.py # POST API routes |
| 13 | +│ └── __init__.py |
| 14 | +├── services/ |
| 15 | +│ ├── logging_service.py # Centralised logging |
| 16 | +│ └── validation_service.py # Queue RO-Crates for validation |
| 17 | +├── tasks/ |
| 18 | +│ └── validation_tasks.py # Validate RO-Crates |
| 19 | +├── utils/ |
| 20 | +│ ├── config.py # Configuration |
| 21 | +│ ├── minio_utils.py # Methods for interacting with MinIO |
| 22 | +│ └── webhook_utils.py # Methods for sending webhooks |
| 23 | +``` |
| 24 | + |
| 25 | +## Setting up the project |
| 26 | + |
| 27 | +### Prerequisites |
| 28 | + |
| 29 | +- Docker with Docker Compose |
| 30 | + |
| 31 | +### Installation |
| 32 | + |
| 33 | +1. Clone the repository: |
| 34 | + ```bash |
| 35 | + git clone https://github.com/eScienceLab/Cratey-Validator.git |
| 36 | + cd crate-validation-service |
| 37 | + ``` |
| 38 | + |
| 39 | +2. Create the `.env` file for shared environment information. An example environment file is included (`example.env`), which can be copied for this purpose. But make sure to change any security settings (username and passwords). |
| 40 | + |
| 41 | +3. Build and start the services using Docker Compose: |
| 42 | + ```bash |
| 43 | + docker compose up --build |
| 44 | + ``` |
| 45 | + |
| 46 | +4. Set up the MinIO bucket |
| 47 | + 1. Open the MinIO web interface at `http://localhost:9000`. |
| 48 | + 2. Log in with your MinIO credentials. |
| 49 | + 3. Create a new bucket named `ro-crates`. |
| 50 | + 4. **Enable versioning** for the `ro-crates` bucket — this is important for tracking unique object versions. |
| 51 | + |
| 52 | +  |
| 53 | + |
| 54 | + 5. Upload your RO-Crate files to the `ro-crates` bucket. |
| 55 | + 6. To verify that versioning is enabled: |
| 56 | + - Select the uploaded RO-Crate object in the `ro-crates` bucket. |
| 57 | + - Navigate to the **Actions** panel on the right. |
| 58 | + - The **Display Object Versions** option should be clickable. |
| 59 | + |
| 60 | +  |
| 61 | + |
| 62 | + |
| 63 | +## Development |
| 64 | + |
| 65 | +For standard usage the Docker Compose script uses prebuilt containers. |
| 66 | +For testing locally developed containers use the alternate Docker Compose file: |
| 67 | +```bash |
| 68 | + docker compose --file docker-compose-develop.yml up --build |
| 69 | +``` |
| 70 | + |
| 71 | +## Example Usage |
| 72 | + |
| 73 | +``` |
| 74 | +curl -X 'POST' \ |
| 75 | + 'http://localhost:5001/ro_crates/validate_by_id_no_webhook' \ |
| 76 | + -H 'accept: application/json' \ |
| 77 | + -H 'Content-Type: application/json' \ |
| 78 | + -d '{ |
| 79 | + "crate_id": "1" |
| 80 | +}' |
| 81 | +``` |
0 commit comments