Skip to content

Commit 5d488bb

Browse files
author
Alan Christie
committed
- Basic/initial fileset
1 parent 0f27d45 commit 5d488bb

File tree

8 files changed

+56
-108
lines changed

8 files changed

+56
-108
lines changed

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
ARG from_image=python:3.9.2-slim-buster
1010
FROM ${from_image}
1111

12-
# Set expected environment variables to default values.
13-
# The actual values are set by the DataTier Manager at run-time.
14-
ENV DT_DATASET_ID=1
15-
ENV DT_ERROR_TEXT_FILE=/dataset/output/error.txt
16-
1712
# All formatter images MUST place their
1813
# implementations (and expect to start) in /home/format-support
1914
WORKDIR /home/format-support
2015

16+
# Copy source code in
17+
COPY source/ ./source/
18+
2119
# Inject the entrypoint,
2220
# making sure anyone can read and execute it.
2321
COPY docker-entrypoint.sh ./

README.md

Lines changed: 11 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,22 @@
11
# format-support-template
22

3-
[![build](https://github.com/InformaticsMatters/format-support-template/actions/workflows/build.yaml/badge.svg)](https://github.com/InformaticsMatters/format-support-template/actions/workflows/build.yaml)
4-
[![publish latest](https://github.com/InformaticsMatters/format-support-template/actions/workflows/publish-latest.yaml/badge.svg)](https://github.com/InformaticsMatters/format-support-template/actions/workflows/publish-latest.yaml)
5-
[![publish tag](https://github.com/InformaticsMatters/format-support-template/actions/workflows/publish-tag.yaml/badge.svg)](https://github.com/InformaticsMatters/format-support-template/actions/workflows/publish-tag.yaml)
6-
[![publish stable](https://github.com/InformaticsMatters/format-support-template/actions/workflows/publish-stable.yaml/badge.svg)](https://github.com/InformaticsMatters/format-support-template/actions/workflows/publish-stable.yaml)
3+
[![build](https://github.com/InformaticsMatters/pdb-support-template/actions/workflows/build.yaml/badge.svg)](https://github.com/InformaticsMatters/pdb-support-template/actions/workflows/build.yaml)
4+
[![publish latest](https://github.com/InformaticsMatters/pdb-support-template/actions/workflows/publish-latest.yaml/badge.svg)](https://github.com/InformaticsMatters/pdb-support-template/actions/workflows/publish-latest.yaml)
5+
[![publish tag](https://github.com/InformaticsMatters/pdb-support-template/actions/workflows/publish-tag.yaml/badge.svg)](https://github.com/InformaticsMatters/pdb-support-template/actions/workflows/publish-tag.yaml)
6+
[![publish stable](https://github.com/InformaticsMatters/pdb-support-template/actions/workflows/publish-stable.yaml/badge.svg)](https://github.com/InformaticsMatters/pdb-support-template/actions/workflows/publish-stable.yaml)
77

8-
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/informaticsmatters/format-support-template)
8+
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/informaticsmatters/pdb-support-template)
99

1010
---
1111

12-
> Replace the following template text with your own documentation
12+
A format-support image for the DataTier service, handling the following
13+
MIME types: -
1314

14-
A template repository for **Informatics Matters DataTier dataset
15-
format-support container image implementations**.
15+
- `chemical/x-pdb`
1616

17-
Use this repository to start development of a container image that can be
18-
used by the DataTier Manager to support the loading of a dataset _type_.
19-
20-
You are required to preserve and adhere to the design rules
21-
that can be found in this repository's `RULES.md`.
22-
23-
Please take time to familiarise yourself with following sections before
24-
discarding this text. Failing to comply with what's discussed here
25-
may result in the image not passing any future automated acceptance testing
26-
that may be deployed.
27-
28-
- Building
29-
- Testing
30-
- Required image tags
31-
- Built-in GitHub Actions
32-
- Updating the badge links
33-
34-
## Building
35-
You should be able to build your format-support image using `docker`: -
36-
37-
$ docker build . -t ${PWD##*/}:latest
38-
39-
Or `docker-compose`: -
40-
41-
$ IMAGE_NAME=${PWD##*/} docker-compose build
42-
43-
> The expectation is that you're using a recent Docker engine
44-
(like `20.10.2`) and docker-compose utility (like `1.27.4`).
45-
46-
## Testing
47-
Familiarise yourself with `TESTING.md`, which describes
48-
a strategy you can replicate while developing and testing your image.
49-
50-
## Required image tags
51-
The DataTier Manager will only execute formatter images tagged `:stable`
52-
so you **MUST** ultimately produce an image with this tag. You are also
53-
encouraged to produce a `:latest` tag and any specific tags that satisfy your
54-
own needs (with formats like `1.0.0-rc.1`, `1.0.0` and `2021.1`).
55-
56-
> This repository's built-in GitHub Actions (see the next section)
57-
will do all this for you.
58-
59-
## Built-in GitHub Actions
60-
The template contains a number of [GitHub Actions] that will automatically
61-
build the container image and also publish `:latest` and any tags you make to
62-
Docker Hub.
63-
64-
This relies on your docker registry mirroring your repository. If your docker
65-
repository name does not mirror your GitHub repository name then you will need
66-
to adjust these actions. For example, if you create a GitHub repository
67-
from this one and call it 'XYZ/my-support-template' then you must be able to
68-
push docker images to 'xyz/my-support-template:latest'. If not, you will need
69-
to edit the workflow files to satisfy your needs.
70-
71-
> Your images must be published to Docker Hub.
72-
73-
The following built-in actions are: -
74-
75-
1. **For every commit to main** an Action builds the docker image and
76-
pushes it using the image tag `:latest`.
77-
This is accomplished by the `publish-latest.yaml` Action.
78-
2. **For every repository tag** an Action builds the docker image and
79-
pushes it with the image tag `:<tag>`
80-
This is accomplished by the `publish-tag.yaml` Action.
81-
- If the tag looks like a _formal_ release, i.e. is a 2 or 3-digit number
82-
like `2021.1` or `1.0.0` an Action builds the docker image and
83-
pushes it using the image tag `:<tag>` and the tag `:stable`
84-
This is accomplished by the `publish-stable.yaml` Action.
85-
3. **For every commit on a branch**, or a pull request to main, an Action
86-
runs that just builds the docker image - but does not push it.
87-
This is accomplished by the `build.yaml` Action.
88-
89-
In order for the above Actions to succeed you will need to define the following
90-
GitHub Repository (or Organisation) **secrets**: -
91-
92-
- `DOCKERHUB_USERNAME` A Docker Hub user
93-
- `DOCKERHUB_TOKEN` A Docker Hub user password or, ideally, access token
94-
95-
> Repositories created in the InformaticsMatters organisation
96-
are already presented with these secrets as they are already
97-
defined at the Organisation level.
98-
99-
## Updating the badge links
100-
Don't forget to replace the `InformaticsMatters/format-support-template`
101-
values in the above badge links with the name of your own repository, otherwise
102-
your badges will reflect the template repository's state, not yours.
17+
For design details and behaviour refer to our [format-support-template]
18+
template repository.
10319

10420
---
10521

106-
[github actions]: https://github.com/features/actions
22+
[format-support-template]: https://github.com/InformaticsMatters/format-support-template

TESTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ Python virtual environment: -
2626

2727
$ IMAGE_NAME=${PWD##*/} docker-compose build
2828

29-
> Ignore the warning about the IMAGE_TEST variable not being set
30-
3129
...and then, simulating the provision of the output directory that would
3230
normally be created by the DataTier Manager, we can run a specific test...
3331

docker-entrypoint.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@
1414
# a directory you can write to
1515
# -----------------------------------------------------------------------------
1616

17-
# Replace this text and the remainder of the file
18-
# with your formatter implementation...
19-
20-
# Format your data...
21-
echo "Hello World!"
17+
python source/formatter.py

source/formatter.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import logging
2+
import os
3+
import time
4+
5+
# Two loggers - one for basic logging, one for events.
6+
basic_logger = logging.getLogger('basic')
7+
basic_logger.setLevel(logging.INFO)
8+
basic_handler = logging.StreamHandler()
9+
basic_formatter = logging.Formatter('%(asctime)s # %(levelname)s %(message)s')
10+
basic_handler.setFormatter(basic_formatter)
11+
basic_logger.addHandler(basic_handler)
12+
13+
event_logger = logging.getLogger('event')
14+
event_logger.setLevel(logging.INFO)
15+
event_handler = logging.StreamHandler()
16+
event_formatter = logging.Formatter('%(asctime)s # %(levelname)s -EVENT- %(message)s')
17+
event_handler.setFormatter(event_formatter)
18+
event_logger.addHandler(event_handler)
19+
20+
# Get and display the environment material
21+
# (guaranteed to be provided)
22+
# using the basic (non-event) logger
23+
dataset_name = os.getenv('DT_DATASET_NAME')
24+
dataset_file = os.getenv('DT_DATASET_FILE')
25+
dataset_output_path = os.getenv('DT_DATASET_OUTPUT_PATH')
26+
27+
basic_logger.error('DT_DATASET_NAME=%s', dataset_name)
28+
basic_logger.info('DT_DATASET_FILE=%s', dataset_file)
29+
basic_logger.info('DT_DATASET_OUTPUT_PATH=%s', dataset_output_path)
30+
31+
# Now enter the formatting logic...
32+
# Here we use the event logger.
33+
event_logger.info('Progress %d%%', 0)
34+
time.sleep(4.0)
35+
event_logger.info('Progress %d%%', 50)
36+
time.sleep(4.0)
37+
event_logger.info('Progress %d%%', 100)

test/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Tests
2+
3+
## success/1
4+
The first 10 entries from our `pdb-ligand/2021-03-02/all-sdf.sdf.gz` reference.

test/success/1/input/dummy.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
3.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)