Launch on mybinder.org:
Open the notebook request.ipynb and run it.
Launch on mybinder.org:
Open the notebook request.ipynb and run it.
| #!/bin/sh | |
| set -eu | |
| # FIVE_SAFES_PROFILE_VERSION=five-safes-0.7.4-beta | |
| FIVE_SAFES_PROFILE_VERSION=five-safes-0.8.0 | |
| PROFILES_ARCHIVE_URL=https://github.com/eScienceLab/rocrate-validator/archive/refs/tags/${FIVE_SAFES_PROFILE_VERSION}.tar.gz | |
| EXTRA_PROFILES_PATH=extra_profiles | |
| git clone https://github.com/eScienceLab/RO-Crate-Validation-Service/ | |
| curl -sSfLo ro-crate-metadata.json https://github.com/eScienceLab/RO-Crate-Validation-Service/raw/refs/heads/develop/tests/data/ro-crate-metadata.json | |
| curl -sSfLo ro-crate-metadata-5s.json https://github.com/eScienceLab/rocrate-validator/raw/refs/heads/develop/tests/data/crates/valid/five-safes-crate-result/ro-crate-metadata.json | |
| mkdir -p "$EXTRA_PROFILES_PATH" | |
| curl -sSfL "$PROFILES_ARCHIVE_URL" | \ | |
| tar -zxv --strip-components=3 -C extra_profiles rocrate-validator-${FIVE_SAFES_PROFILE_VERSION}/rocrate_validator/profiles/five-safes-crate |
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "41a83401-0d88-4f89-a435-544c79416303", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import os\n", | |
| "import requests\n", | |
| "import sys\n", | |
| "import threading\n", | |
| "from werkzeug.serving import make_server\n", | |
| "\n", | |
| "sys.path.insert(0, \"RO-Crate-Validation-Service\")\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "c66e7022-27c6-4836-bd45-682b270eb093", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "# os.environ[\"FLASK_APP\"] = \"RO-Crate-Validation-Service/wsgi.py\"\n", | |
| "os.environ[\"FLASK_ENV\"] = \"development\"\n", | |
| "os.environ[\"EXTRA_PROFILES_PATH\"] = \"extra_profiles\"\n", | |
| "\n", | |
| "from app import create_app\n", | |
| "from app.services.logging_service import setup_logging\n", | |
| "\n", | |
| "app = create_app()\n", | |
| "setup_logging(app.config[\"SETTINGS\"])\n", | |
| "server = make_server(\"127.0.0.1\", 5000, app)\n", | |
| "\n", | |
| "def run_server():\n", | |
| " print(\"Starting Flask application in the background...\")\n", | |
| " server.serve_forever()\n", | |
| "\n", | |
| "flask_thread = threading.Thread(target=run_server, daemon=True)\n", | |
| "flask_thread.start()\n", | |
| "\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "59a0f77a-8c9e-4f10-b68c-54b739f828bc", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "2933feed-baa2-4249-bcbf-fa0c5f8677a8", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "BASE_URL = \"http://localhost:5000\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "56eb7139-1131-440b-8513-aa8945ece7f8", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "\n", | |
| "with open(\"ro-crate-metadata.json\", encoding=\"utf-8\") as f:\n", | |
| " crate_json = f.read()\n", | |
| "\n", | |
| " response = requests.post(\n", | |
| " f\"{BASE_URL}/v1/ro_crates/validate_metadata\",\n", | |
| " json={\"crate_json\": crate_json},\n", | |
| " )\n", | |
| "\n", | |
| " assert response.status_code == 200\n", | |
| " body = response.json()\n", | |
| " display(body)\n", | |
| " assert body[\"status\"] == \"valid\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "6ad51aea-08ba-401e-9b6d-3255565875e8", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "\n", | |
| "with open(\"ro-crate-metadata-5s.json\", encoding=\"utf-8\") as f:\n", | |
| " crate_json = f.read()\n", | |
| "\n", | |
| " response = requests.post(\n", | |
| " f\"{BASE_URL}/v1/ro_crates/validate_metadata\",\n", | |
| " json={\"crate_json\": crate_json, \"profile_name\": \"five-safes-crate\"},\n", | |
| " )\n", | |
| "\n", | |
| " assert response.status_code == 200\n", | |
| " body = response.json()\n", | |
| " display(body)\n", | |
| " assert body[\"status\"] == \"valid\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "a9f4034c-0a39-46ab-bcc1-cb5d4bf8f0da", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "print(\"Stopping Flask application...\")\n", | |
| "server.shutdown()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "dddb35bd-ff45-4d92-bc9b-dc631ec7a024", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3 (ipykernel)", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.14.0" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
| git+https://github.com/eScienceLab/RO-Crate-Validation-Service.git |
| python-3.14 |