Package: lts-mpsmqutils
mps-mqutilsIntroductionA set of utilities for Media Preservation Services that provides standard methods to communicate with the message queue.PrerequisitesRead the README in the worker prototype projectmps-worker-prototypefor information on how to build and integrate a worker microservice. Read theWORKER PROGRAMMINGsection for the standard worker API request and responses that are required.Example worker API responsesTask was successful:{ success: 'true' }Task did not complete successfully:{ success: 'false', 'error': 'Example error', 'message': 'Example error message' }Technology StackLanguagePythonDevelopment OperationsDocker ComposeConfigurationThis 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 Instructions1: Clone the repository to a local directorygit clonegit@github.huit.harvard.edu:LTS/mps-mqutils.git2: Create app configCreate config file for environment variablesMake a copy of the config example file./env-example.txtRename the file to.envReplace placeholder values as necessaryNote: 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: StartSTARTTo 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-recreate4: Open a shell in the containerRun docker exec to execute a shell in the container by nameOpen a shell using the exec command to access the mps-mqutils container.docker exec -it mps-mqutils bash5: Install dependenciesThis step is only required if additional python dependencies must be installed. Update the requirements.txt inside the container to install new python packages in the project. If the dependencies are required for the package to run, they also must be included in theinstall_requiressection of setup.py.Install a new pip packageOnce inside the mps-mqutils container, run the pip install command to install a new package and update the requirements text file.pip install packagename && pip freeze > requirements.txtAdd dependencies to setupAdd the names of the dependencies to theinstall_requiressection of setup.py. Read more about adding dependencies in this articleSpecifying dependencies.6: Build and publish the packageStep 6A: Prepare the distributionUpdate the version number insetup.pyTo publish a pre-release version, add a letter and a number after the version number e.g.0.0.1a1Remove the olddist/directory from the previous build if necessaryStep 6B: Build the distributionOnce inside the container, build the distribution.python3 setup.py sdist bdist_wheelA new directorydistwill be created in the container.Step 6C: Register for an accountRegister for an accounton the test python package repository. Enable two-factor authentication for logins.Create a token.Step 6D: Upload package to the test repositoryPublish the package to the test repositorytestpypibefore publishing it to the production repository.python3 -m twine upload --repository testpypi dist/*Step 6E: Test the packageOpen the package in the repository and view the version history.https://test.pypi.org/project/lts-mpsmqutils/0.0.1/ReadInstallationin this document for instructions on how to install and test the package in another project or environment.7: StopSTOP AND REMOVEThis 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 downMore informationRead the documenation for more information on building and publishing the distribution.Generating distribution archivesUploading the distribution archiveshttps://tom-christie.github.io/articles/pypi/