Python code for the DOR project.
- Clone the repo
git clone https://github.com/mlibrary/dor-py.git
cd dor-py- In the terminal, run the
init.sh
./init.shThis will:
- set up the initial environment variables file
- build the docker image
- install the python dependencies
./init.sh can be run more than once.
-
Edit
.envwith actual environment variables -
In the app container, use
poetry shellto enable the virtual environment. Otherwise use:
docker compose run --rm app poetry run YOUR_COMMANDBehavior driven development (BDD) with pytest-bdd
Test driven development (TDD) with pytest
To run the features located in the 'features' directory and tests located in the tests directory, use the following command:
docker compose run --rm app poetry run pytestSome operations and tests rely on a PostgreSQL database that can be run using a separate Docker service. Use the following command to start up the database.
docker compose up dbThe application provides a few REST API endpoints for reporting purposes.
Use the following command to start up the server.
API documentation for the routes will be available at http://0.0.0.0:8000/docs,
or using a different port if you set the API_PORT environment variable to a different value.
docker compose up apiTo generate sample packages, on the command line run:
docker compose run --rm app poetry run dor samples generate --collid xyzzy --num-scans 5 --versions 1This will generate a submission package in BagIt format for the collection xyzzy for one item made up of 5 page scans.
To see all options:
docker compose run --rm app poetry run dor samples generate --helpHow does the versions option work? The first version of the item will contain all the scans.
The next versions will only contain a random subset of updated scans.
Can you validate the METS2 documents? The schemas for METS2 and PREMIS3 are in the etc/xsd
directory. With xmllint --schema you can only use one of these schemas, so validating a METS2
document will always complain about the PREMIS:object type.