A job tracker management module
Project description
mps-job-tracker
Introduction
A job tracker service for Media Preservation Services that provides standard methods to create and manage job tracker files in the Asset Ingest message queue.
Technology Stack
Language
Python
Development Operations
Docker Compose
Configuration
This package reads configuration values from environment variables.
Jobs directory
When importing this package in another project
The package writes job tracker files to a directory specified in the environment variable JOB_DATA_BASEDIR
. When importing this package into another project, set this environment variable to the path of the jobs directory.
When using this project
In this project, the job tracker directory is set in the environment variables configuration file .env
. The job tracker directory should be set to the jobs directory inside the container.
JOB_DATA_BASEDIR=/home/appuser/jobs/
The docker-compose file in this project mounts the jobs directory from inside the container to a local directory on the host filesystem. In this configuration, the jobs will be written to /home/appuser/jobs
inside the container and that directory is mounted to the ./jobs
directory on the host filesystem.
volumes:
# App
- './:/home/appuser'
# Jobs
- './jobs:/home/appuser/jobs'
Installation
$ pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ lts-mpsjobtracker==0.0.3
$ python
>>> import mpsjobtracker.trackers.jobtracker as jobtracker
>>> jt = jobtracker.JobTracker()
>>> jt.init_tracker_file('create_asset')
{'job_ticket_id': '39aa64a5-7451-45fc-b5bd-68d1bf02b31e-43e85fab1540', 'job_name': 'create_asset', 'job_management': {'current_step': 1, 'steps': {'1': 'generate_mock_manifest', '2': 'retrieve_image_from_origin', '3': 'check_jp2_compliance', '4': 'create_thumbnails', '5': 'save_to_storage', '6': 'save_data'}, 'job_status': '', 'previous_step_status': ''}, 'context': {}, 'creation_date': '2020-11-10 22:24:00', 'last_modified_date': '2020-11-10 22:24:00'}
Local Development Environment Setup Instructions
1: Clone the repository to a local directory
git clone git@github.huit.harvard.edu:LTS/mps-job-tracker.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
This command builds the docker image runs the container specified in the docker-compose.yml configuration.
docker-compose up --build --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-job-tracker container.
docker exec -it mps-job-tracker bash
5: Install dependencies
This 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 the install_requires
section of setup.py.
Install a new pip package
Once inside the mps-job-tracker container, run the pip install command to install a new package and update the requirements text file.
pip install packagename && pip freeze > requirements.txt
Add dependencies to setup
Add the names of the dependencies to the install_requires
section of setup.py. Read more about adding dependencies in this article Specifying dependencies.
6: Build and publish the package
Step 6A: Prepare the distribution
- Update the version number in
setup.py
- 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-mpsjobtracker/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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lts-mpsjobtracker-0.0.15.tar.gz
.
File metadata
- Download URL: lts-mpsjobtracker-0.0.15.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07cc3e2688d17ddcbdfc44be61012b45e820adfa2c11eaa06d3d901354fced9f |
|
MD5 | c7525ed22704b9288dac2c64c8a24343 |
|
BLAKE2b-256 | cb1d6b701629ba5a7c9a96eba5ecfd591214a6979e909fdef2d271a479089720 |
File details
Details for the file lts_mpsjobtracker-0.0.15-py3-none-any.whl
.
File metadata
- Download URL: lts_mpsjobtracker-0.0.15-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f76bb26a7001b20681daa4e860a0c09c3c2e1bbcccfde46e2e2602c3bd1719a9 |
|
MD5 | c36f1a5b6f03c554cb18b86e21244138 |
|
BLAKE2b-256 | 87b99df8d2b9ce734d0aeec3d41f7f14de1047e73bf8fc70928e79075504c673 |