Skip to main content

mps-mqutils

Introduction

A set of utilities for Media Preservation Services that provides standard methods to communicate with the message queue.

Prerequisites

Read the README in the worker prototype project mps-worker-prototype for information on how to build and integrate a worker microservice. Read the WORKER PROGRAMMING section for the standard worker API request and responses that are required.

Example worker API responses

Task was successful:

{ success: 'true' }

Task did not complete successfully:

{ success: 'false', 'error': 'Example error', 'message': 'Example error message' }

Technology Stack

Language

Python

Development Operations

Docker Compose

Configuration

This package reads configuration values from environment variables.

Installation

$ pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ lts-mpsmqutils
$ python
>>> from mpsmqutils import mqlistener, mqutils
>>> mqutils.__create_message('0922a78fd89f_2a5ff037-462a-4642-8bd0-7546d7580e1a', 1, 'success')

Local Development Environment Setup Instructions

1: Clone the repository to a local directory

git clone git@github.huit.harvard.edu:LTS/mps-mqutils.git

2: Create app config

Create config file for environment variables
  • Make a copy of the config example file ./env-example.txt
  • Rename the file to .env
  • Replace placeholder values as necessary

Note: The config file .env is specifically excluded in .gitignore and .dockerignore, since it contains credentials it should NOT ever be committed to any repository.

3: Start

START

To build the image without the cache, run the build command with the --no-cache option. The no cache option is required when updating any dependencies.

docker-compose -f docker-compose-local.yml build --no-cache && docker-compose -f docker-compose-local.yml up -d --force-recreate

4: Open a shell in the container

Run docker exec to execute a shell in the container by name

Open a shell using the exec command to access the mps-mqutils container.

docker exec -it mps-mqutils bash

5: Install dependencies

This step is only required if additional python dependencies must be installed. setup.py is the single source of truth for dependencies — the Docker image installs the package from it, so there is no requirements.txt to maintain.

Add a new dependency

Add the name of the dependency to the install_requires section of setup.py. Read more about adding dependencies in this article Specifying dependencies.

Then rebuild the image so the new dependency is installed. The --no-cache option is required when updating any dependencies.

docker-compose -f docker-compose-local.yml build --no-cache && docker-compose -f docker-compose-local.yml up -d --force-recreate

To try a package out before committing to it, you can also pip install packagename inside the running container, but that change is lost on rebuild unless it is added to install_requires.

6: Build and publish the package

Step 6A: Prepare the distribution

  • Update the version number in setup.py
  • To publish a pre-release version, add a letter and a number after the version number e.g. 0.0.1a1
  • Remove the old dist/ directory from the previous build if necessary

Step 6B: Build the distribution

Once inside the container, build the distribution.

python3 setup.py sdist bdist_wheel

A new directory dist will be created in the container.

Step 6C: Register for an account

Register for an account on the test python package repository. Enable two-factor authentication for logins. Create a token.

Step 6D: Upload package to the test repository

Publish the package to the test repository testpypi before publishing it to the production repository.

python3 -m twine upload --repository testpypi dist/*

Step 6E: Test the package

Open the package in the repository and view the version history.

https://test.pypi.org/project/lts-mpsmqutils/0.0.1/

Read Installation in this document for instructions on how to install and test the package in another project or environment.

7: Stop

STOP AND REMOVE

This command stops and removes all containers specified in the docker-compose-local.yml configuration. This command can be used in place of the 'stop' and 'rm' commands.

docker-compose -f docker-compose-local.yml down

More information

Read the documenation for more information on building and publishing the distribution.

Release files for lts-mpsmqutils 2.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lts-mpsmqutils 2.1.6
File Size Uploaded
lts_mpsmqutils-2.1.6.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lts-mpsmqutils 2.1.6
File Interpreter ABI Platform
lts_mpsmqutils-2.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 25.5 kB

Release files / lts_mpsmqutils-2.1.6.tar.gz

Download URL lts_mpsmqutils-2.1.6.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
98664dff869886a2ef89e6061419bb0ff7cf8fbab20943c5209de214ebbf0fbc
BLAKE2b-256 checksum
How to use checksums
1e4e04a378ef92e8c23609a5279a1633036dd07a45b08a0629ad0d819834f1b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / lts_mpsmqutils-2.1.6-py3-none-any.whl

Download URL lts_mpsmqutils-2.1.6-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
72fde4f7b95488342396a1be38b00eee5f712e3f49c18f3fc0f9564cd1b0afd6
BLAKE2b-256 checksum
How to use checksums
16177867c3c3614d9acd56d970f086d797518ef5adfb5e24abb2798f6ba64da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

2.1.6 This release

2 release files

2.1.5

1 release file

2.1.4

1 release file

2.1.3

1 release file

2.1.2

2 release files

2.1.1

1 release file

2.1.0

2 release files

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

0.0.92

1 release file

0.0.91

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page