Skip to content
This repository was archived by the owner on Nov 14, 2022. It is now read-only.

Commit 05d4481

Browse files
authored
Mantid versions: latest & nightly (#1463)
* Create a Dockerfile with Python 3.8, qp from the local repo, and currently the latest Mantid (6.4.0) * Update PYTHONPATH to reflect where the Mantid packages and scripts are located * Add Dockerfile to package queue-processor without Mantid * Pass required Mantid version in as an arg, reducing need for multiple similar Dockerfiles * Not sure if required currently, part of the old Dockerfile so should be seen if it is needed * Delete old Dockerfile * Move copy to builder * Move conda-pack to root (base) environment - the conda-pack command will then be available in all sub-environments as well * Pypi package of mysqlclient needed the libs on the OS in order to install - therefore these are installed on both the builder and the runner * Add ARG for whether to download nightly version of Mantid. Use if statement to download latest stable or latest nightly. * Refacot references from Mantid 6.2.0 to Mantid Latest * Fix pylint spacing
1 parent 21d07f6 commit 05d4481

File tree

9 files changed

+94
-66
lines changed

9 files changed

+94
-66
lines changed

autoreduce_qp/queue_processor/reduction/tests/common.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def add_data_and_message():
2727
'description': 'This is a test',
2828
'software': {
2929
"name": "Mantid",
30-
"version": "6.2.0",
30+
"version": "latest",
3131
},
3232
}
3333

@@ -36,40 +36,6 @@ def add_data_and_message():
3636
return data, message
3737

3838

39-
def expected_return_data_and_message():
40-
"""
41-
Makes and returns some test data and message
42-
"""
43-
data = {
44-
'data': '\\\\isis\\inst$\\NDXTESTINSTRUMENT\\Instrument\\data\\cycle_21_1\\data.nxs',
45-
'facility': 'ISIS',
46-
'instrument': 'TESTINSTRUMENT',
47-
'rb_number': '1234',
48-
'run_number': '4321',
49-
'run_version': 1,
50-
'reduction_script': 'print("hello")', # not actually used for the reduction
51-
'reduction_arguments': {
52-
"standard_vars": {
53-
"arg1": "differentvalue",
54-
"arg2": 321
55-
},
56-
"advanced_vars": {
57-
"adv_arg1": "advancedvalue2",
58-
"adv_arg2": ""
59-
}
60-
},
61-
'description': 'This is a test',
62-
'software': "6.2.0",
63-
"reduction_data": "/instrument/TESTINSTRUMENT/RBNumber/RB1234/autoreduced/Test run name/run-version-1",
64-
"reduction_log":
65-
"Running reduction script: /isis/NDXTESTINSTRUMENT/user/scripts/autoreduction/reduce.py\nHello\n"
66-
}
67-
68-
message = Message()
69-
message.populate(data)
70-
return data, message
71-
72-
7339
def add_bad_data_and_message():
7440
"""
7541
Makes and returns some test data and message

autoreduce_qp/queue_processor/reduction/tests/test_process_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
from autoreduce_db.reduction_viewer.models import Software
1313

1414
from autoreduce_qp.queue_processor.reduction.process_manager import ReductionProcessManager
15-
from autoreduce_qp.queue_processor.reduction.tests.common import (add_bad_data_and_message, add_data_and_message,
16-
expected_return_data_and_message)
15+
from autoreduce_qp.queue_processor.reduction.tests.common import (add_bad_data_and_message, add_data_and_message)
1716

1817

1918
class TestReductionProcessManager(unittest.TestCase):
2019

2120
def setUp(self) -> None:
2221
self.data, self.message = add_data_and_message()
23-
self.expected_data, self.expected_message = expected_return_data_and_message()
2422
self.bad_data, self.bad_message = add_bad_data_and_message()
2523
self.run_name = "Test run name"
26-
self.software = Software(name="Mantid", version="6.2.0")
24+
self.software = Software(name="Mantid", version="latest")
2725

2826
def test_init(self):
2927
"""Test that the constructor is doing what's expected"""

autoreduce_qp/queue_processor/reduction/tests/test_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_reduce_throws_reductionscripterror(self, reduce: Mock, _get_mantid_vers
184184
assert runner.message.reduction_data is None
185185
assert runner.message.software == {
186186
"name": "Mantid",
187-
"version": "6.2.0",
187+
"version": "latest",
188188
}
189189
assert "Error encountered when running the reduction script" in runner.message.message
190190

@@ -206,7 +206,7 @@ def test_reduce_throws_any_exception(self, reduce: Mock, _get_mantid_version: Mo
206206
assert runner.message.reduction_data is None
207207
assert runner.message.software == {
208208
"name": "Mantid",
209-
"version": "6.2.0",
209+
"version": "latest",
210210
}
211211
assert "REDUCTION Error:" in runner.message.message
212212

@@ -233,7 +233,7 @@ def test_reduce_ok(self, datafile_type: str, reduce: Mock, _get_mantid_version:
233233
assert runner.message.message is None
234234
assert runner.message.software == {
235235
"name": "Mantid",
236-
"version": "6.2.0",
236+
"version": "latest",
237237
}
238238

239239
@staticmethod

autoreduce_qp/queue_processor/reduction/tests/test_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_get_correct_image(self):
6161
client = docker.from_env()
6262
test_software = MagicMock()
6363
test_software.name = "Mantid"
64-
test_software.version = "6.2.0"
64+
test_software.version = "latest"
6565
image = get_correct_image(client, test_software)
6666
self.assertIsNotNone(image)
6767

autoreduce_qp/queue_processor/tests/test_handle_message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def make_test_message(instrument: str) -> Message:
3838
"data": "/path",
3939
'software': {
4040
"name": "Mantid",
41-
"version": "6.2.0",
41+
"version": "latest",
4242
},
4343
"description": "This is a fake description",
4444
"instrument": instrument, # Autoreduction Mock Instrument
@@ -67,7 +67,7 @@ def setUp(self):
6767

6868
self.experiment, _ = Experiment.objects.get_or_create(reference_number=1231231)
6969
self.instrument, _ = Instrument.objects.get_or_create(name=self.instrument_name, is_active=True)
70-
self.software, _ = Software.objects.get_or_create(name="Mantid", version="6.2.0")
70+
self.software, _ = Software.objects.get_or_create(name="Mantid", version="latest")
7171
status = Status.get_queued()
7272
self.reduction_run, self.message = create_reduction_run_record(self.experiment, self.instrument, self.msg, 0,
7373
status, self.software)

autoreduce_qp/systemtests/base_systemtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def setUp(self):
6868
self.run_title = "test title"
6969
self.software = {
7070
"name": "Mantid",
71-
"version": "6.2.0",
71+
"version": "latest",
7272
}
7373

7474
# Create test archive and add data

container/qp_mantid_python36.D

Lines changed: 0 additions & 20 deletions
This file was deleted.

container/qp_py38.Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ghcr.io/autoreduction/base
2+
3+
# Installs queue-processor from your local repository
4+
ADD . .
5+
RUN python3 -m pip install --user --no-cache-dir .
6+
7+
CMD autoreduce-qp-start
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
FROM continuumio/miniconda3 AS build
2+
3+
ARG NIGHTLY=False
4+
WORKDIR /app
5+
ADD . .
6+
7+
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update &&\
8+
apt-get install -y \
9+
wget \
10+
gnupg \
11+
git \
12+
software-properties-common \
13+
python3-dev \
14+
default-libmysqlclient-dev \
15+
build-essential \
16+
gcc
17+
18+
# Install conda-pack into the base environment
19+
RUN conda install conda-pack
20+
21+
# Create the conda environment
22+
RUN conda create -n py38 python=3.8.12
23+
24+
# Make RUN, CMD, and ENTRYPOINT commands use the new environment with the SHELL command
25+
SHELL [ "conda", "run", "-n", "py38", "/bin/bash", "-c" ]
26+
27+
# Install Mantid and install autoreduce-qp from local directory
28+
RUN conda config --add channels conda-forge
29+
RUN if [ "$NIGHTLY" = "False" ]; then \
30+
conda install mantid -c mantid; \
31+
else \
32+
conda install -c mantid/label/nightly mantid; \
33+
fi
34+
35+
RUN python3 -m pip install --no-cache-dir .
36+
RUN python3 -m pip install --no-cache-dir mysqlclient debugpy
37+
38+
# Use conda-pack to create a standalone enviornment in /venv:
39+
RUN conda-pack -n py38 -o /tmp/env.tar && \
40+
mkdir /venv && cd /venv && tar xf /tmp/env.tar && \
41+
rm /tmp/env.tar
42+
43+
RUN cp /venv/bin/Mantid.properties /venv/lib/Mantid.properties
44+
45+
# We've put venv in same path it'll be in final image,
46+
# so now fix up paths:
47+
RUN /venv/bin/conda-unpack
48+
49+
50+
51+
FROM debian:buster AS runtime
52+
53+
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update &&\
54+
apt-get install -y \
55+
wget \
56+
gnupg \
57+
git \
58+
software-properties-common \
59+
python3-dev \
60+
default-libmysqlclient-dev \
61+
build-essential \
62+
gcc
63+
64+
RUN useradd -m --no-log-init -s /bin/bash -u 880844730 isisautoreduce
65+
USER isisautoreduce
66+
WORKDIR /home/isisautoreduce
67+
68+
COPY --from=build /venv /venv
69+
70+
ENV PYTHONPATH=/venv/scripts/:/venv/scripts/Diffraction/:/venv/scripts/Engineering/:/venv/bin:/venv/lib:/venv/plugins:/venv/scripts/SANS/:/venv/scripts/Inelastic/:/venv/scripts/ExternalInterfaces:/venv/scripts/Interface
71+
72+
# Add the environment to the PATH (equivalent of running source /venv/bin/activate)
73+
ENV PATH="/venv/bin:$PATH"
74+
75+
# When the image is run, run the code with the environment
76+
SHELL [ "/bin/bash", "-c" ]
77+
CMD autoreduce-qp-start

0 commit comments

Comments
 (0)