An open API service indexing awesome lists of open source software.

https://github.com/mardi4nfdi/mardi_doip_server

A simple server implementing the DOIP v2 (Digital Object Interface Protocol)
https://github.com/mardi4nfdi/mardi_doip_server

Last synced: 20 days ago
JSON representation

A simple server implementing the DOIP v2 (Digital Object Interface Protocol)

Awesome Lists containing this project

README

          

# Mardi DOIP Server

Asyncio-based DOIP 2.0 TCP server that fronts the MARDI FDO infrastructure. The server listens on port 3567, uses strict DOIP binary envelopes, streams components from lakeFS (S3-compatible), and integrates with the FDO FastAPI façade and a MediaWiki/Wikibase backend for derived items.

## Documentation
[![Documentation](https://img.shields.io/badge/docs-gh--pages-blue)](https://mardi4nfdi.github.io/mardi_doip_server/)

- Built with MkDocs; see `docs/build_docs.sh` or browse source in `docs/content/`.

## Getting Started
- Requirements:
- `pip install -r requirements.txt`.
- Configuration:
- Either create `config.yaml` and set configuration details.
- Or use environment variables - they override values from the config file where applicable
- `LAKEFS_USER` / `LAKEFS_PASSWORD`
- `LAKEFS_URL` / `LAKEFS_REPO`
- `FDO_API`
- `OLLAMA_API_KEY`

Run the server:
```bash
python -m doip_server.main # binds 0.0.0.0:3567
```
or, to use a custom FDO server endpoint:
```bash
python -m doip_server.main --fdo-api http://127.0.0.1:8000/fdo/
```

## Getting started with Docker

The Docker version has an additional HTTP gateway to use the DOIP service.
Example: `/doip/retrieve/{object_id}/{component_id}` (This would stream the given component as file download.)
Or, using curl:
```bash
curl -OJ http://localhost/doip/retrieve/Q123/fulltext
```

Build the image (from repo root):
```bash
docker build -f docker/Dockerfile -t mardi-doip .
```

Run with TLS (default self-signed cert generated during build):
```bash
docker run --rm \
-p 80:80 -p 3567:3567 -p 3568:3568 \
-e FDO_API=https://fdo.portal.mardi4nfdi.de/fdo/ \
-e LAKEFS_URL= \
-e LAKEFS_USER= -e LAKEFS_PASSWORD= -e LAKEFS_REPO= \
mardi-doip
```

Example hello via client CLI against the container:
```bash
python -m client_cli.main --host localhost --port 3567 --action hello
```

## Examples

### Run the client CLI:

Retrieve meta-data about an FDO, e.g. a publication with QID Q6190920:

```bash
PYTHONPATH=. python -m client_cli.main --host 127.0.0.1 --no-tls --action retrieve --object-id Q6190920
```

Retrieve the fulltext pdf from a FDO publication:

```bash
PYTHONPATH=. python -m client_cli.main --host 127.0.0.1 --no-tls --action retrieve --object-id Q6190920 --component fulltext.pdf --output pdf.pdf
```

Update one component on an existing FDO and create a mandatory lakeFS commit:

```bash
PYTHONPATH=. python -m client_cli.main --host 127.0.0.1 --no-tls --action update --object-id Q6190920 --component fulltext.pdf --input pdf.pdf --media-type application/pdf
```

### Use the DOIP client in Python:
```python
from doip_client import StrictDOIPClient

client = StrictDOIPClient(host="127.0.0.1", port=3567, use_tls=False)
hello = client.hello()
metadata = client.retrieve("Q123").metadata_blocks
update = client.update_component("Q123", "fulltext.pdf", b"pdf-bytes", media_type="application/pdf")
```

Component IDs are exact storage names. No file extension is added automatically. If you store `fulltext`, retrieve `fulltext`. If you store `fulltext.pdf`, retrieve `fulltext.pdf`.

## TLS (optional):
- Place `certs/server.crt` and `certs/server.key` (PEM) to enable TLS automatically; otherwise the server speaks plaintext DOIP.
- A compatibility listener runs on port 3568 (same TLS setting) accepting doipy JSON-segmented requests and bridging to the DOIP handlers.

## CLI Releases

[![GitHub Release](https://img.shields.io/github/v/release/MaRDI4NFDI/mardi_doip_server)](https://github.com/MaRDI4NFDI/mardi_doip_server/releases/latest)
[![Build Status](https://github.com/MaRDI4NFDI/mardi_doip_server/actions/workflows/build-doip-cli-binary.yml/badge.svg)](https://github.com/MaRDI4NFDI/mardi_doip_server/actions/workflows/build-doip-cli-binary.yml)

Pre-built binaries for Windows, macOS, and Linux are available on the [releases page](https://github.com/MaRDI4NFDI/mardi_doip_server/releases). Download the binary for your platform and run it directly — no Python installation required.

```bash
# Example: create a new item
mardi-doip-cli --host doip.portal.mardi4nfdi.org --action create \
--json '{"label":"Jane Doe","claims":{"P31":"Q57162","P1460":"Q5976445"}}' \
--token
```