Skip to content

Commit 3684b32

Browse files
ndg63276Mark Williamsgfrn
authored
Merge pre-release/2024-R5.4 with master (#892)
* LIMS-1569: Get image viewer rings from dials if possible (#875) * LIMS-1002: Fix error when creating new laboratory (#815) * LIMS-1302 - add visit to container even if UAS fails (#762) * LIMS-1487: Fix alphafold triggering (#866) * LIMS-1563 - Remove touchscreen app (#867) Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk> Co-authored-by: Guilherme Francisco <guilherme.de-freitas@diamond.ac.uk>
1 parent 7eb2aab commit 3684b32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+95
-29246
lines changed

api/config_sample.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@
128128
$enabled_container_types = array();
129129

130130
# Zocalo message broker credentials - Set to empty string to disable
131-
$zocalo_server = 'tcp://activemq.server.ac.uk';
132-
$zocalo_username = 'foo';
133-
$zocalo_password = 'bar';
134-
135-
# Primary Zocalo entry point for recipe submission
136-
$zocalo_mx_reprocess_queue = '/queue/zocolo.name';
131+
$rabbitmq_zocalo_host = 'rabbitmq.server.ac.uk';
132+
$rabbitmq_zocalo_port = 5672;
133+
$rabbitmq_zocalo_username = 'foo';
134+
$rabbitmq_zocalo_password = 'bar';
135+
$rabbitmq_zocalo_vhost = 'zocalo';
136+
$rabbitmq_zocalo_routing_key = 'processing_recipe';
137137

138138
# This is used to trigger Zocalo recipes on adding new Protein sequences
139139
# Set to empty string to disable
@@ -193,18 +193,6 @@
193193
$in_contacts = array('Ind Contact' => 'in@server.ac.uk'
194194
);
195195

196-
197-
# Beamline Sample Registration Machines
198-
# - Used for touchscreen application (unauthenticated)
199-
$blsr = array('1.2.3.4', # my touchscreen computer
200-
);
201-
202-
# Beamline Sample Registration IP -> Beamline mapping
203-
# - Third part of ip is used to identify beamline
204-
#  x.x.103.x => i03
205-
$ip2bl = array(103 => 'i03',
206-
);
207-
208196
# Barcode readers
209197
# - These clients use the android app (unauthenticated)
210198
$bcr = array('1.2.3.4', # my android device
@@ -393,4 +381,5 @@
393381
# Dials server values
394382
$dials_rest_url = "";
395383
$dials_rest_jwt = "";
384+
$dials_rest_url_rings = false;
396385
?>

api/index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ function setupApplication($mode): Slim
7171
$facility_courier_countries, $facility_courier_countries_nde, $facility_courier_countries_link,
7272
$dhl_enable, $scale_grid, $scale_grid_end_date, $preset_proposal, $timezone,
7373
$valid_components, $enabled_container_types, $ifsummary, $synchweb_version, $redirects,
74-
$shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments;
74+
$shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments,
75+
$dials_rest_url_rings;
7576
$app->contentType('application/json');
7677
$options = $app->container['options'];
7778
$app->response()->body(json_encode(array(
@@ -95,6 +96,7 @@ function setupApplication($mode): Slim
9596
'synchweb_version' => $synchweb_version,
9697
'shipping_service_app_url' => $use_shipping_service_redirect || $use_shipping_service_redirect_incoming_shipments ? $shipping_service_app_url : null,
9798
'shipping_service_app_url_incoming' => $use_shipping_service_redirect_incoming_shipments ? $shipping_service_app_url : null,
99+
'dials_rest_url_rings' => $dials_rest_url_rings,
98100
'redirects' => $redirects
99101
)));
100102
});

api/src/Controllers/AssignController.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AssignController extends Page
1313

1414
public static $arg_list = array('visit' => '\w+\d+-\d+', 'cid' => '\d+', 'did' => '\d+', 'pos' => '\d+', 'bl' => '[\w\-]+');
1515

16-
public static $dispatch = array(array('/visits(/:visit)', 'get', 'getBeamlineVisits'),
16+
public static $dispatch = array(
1717
array('/assign', 'get', 'assignContainer'),
1818
array('/unassign', 'get', 'unassignContainer'),
1919
array('/deact', 'get', 'deactivateDewar'),
@@ -74,30 +74,6 @@ function deactivateDewar()
7474
}
7575
}
7676

77-
78-
# ------------------------------------------------------------------------
79-
# Return visits for beamline
80-
function getBeamlineVisits($visit = null)
81-
{
82-
$visits = $this->blsr_visits();
83-
84-
if ($visit)
85-
{
86-
foreach ($visits as $i => $v)
87-
{
88-
if ($v['VISIT'] == $visit)
89-
{
90-
$this->_output($v);
91-
return;
92-
}
93-
}
94-
$this->_error('No such visit');
95-
}
96-
else
97-
$this->_output($visits);
98-
}
99-
100-
10177
# ------------------------------------------------------------------------
10278
# Puck names from puck scanner
10379
# BL03I-MO-ROBOT-01:PUCK_01_NAME

api/src/Controllers/AuthenticationController.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function check()
8989

9090
private function checkAuthRequiredForSpecificSituations($parts): bool
9191
{
92-
global $blsr, $bcr, $img, $auto;
92+
global $bcr, $img, $auto;
9393

9494
$need_auth = true;
9595
# Work around to allow beamline sample registration without CAS authentication
@@ -102,10 +102,6 @@ private function checkAuthRequiredForSpecificSituations($parts): bool
102102
# Allow formulatrix machines unauthorised access to inspections, certain IPs only
103103
($parts[0] == 'imaging' && $parts[1] == 'inspection' && in_array($_SERVER["REMOTE_ADDR"], $img)) ||
104104

105-
# For use on the touchscreen computers in the hutch.
106-
# Handles api calls: /assign/visits/<vist> e.g./assign/visits/mx1234-1
107-
($parts[0] == 'assign' && $parts[1] == 'visits' && in_array($_SERVER["REMOTE_ADDR"], $blsr)) ||
108-
109105
# Allow barcode reader ips unauthorised access to add history
110106
($parts[0] == 'shipment' && $parts[1] == 'dewars' && $parts[2] == 'history' && in_array($_SERVER["REMOTE_ADDR"], $bcr)) ||
111107

@@ -129,11 +125,6 @@ private function checkAuthRequiredForSpecificSituations($parts): bool
129125
else if (sizeof($parts) >= 2)
130126
{
131127
if (
132-
# For use on the touchscreen computers in the hutch
133-
# Handles api calls: /assign/assign, /assign/unassign, /assign/deact, /assign/visits
134-
(($parts[0] == 'assign') && in_array($_SERVER["REMOTE_ADDR"], $blsr)) ||
135-
(($parts[0] == 'shipment' && $parts[1] == 'containers') && in_array($_SERVER["REMOTE_ADDR"], $blsr)) ||
136-
137128
# Allow barcode reader unauthorised access, same as above, certain IPs only
138129
($parts[0] == 'shipment' && $parts[1] == 'dewars' && in_array($_SERVER["REMOTE_ADDR"], $bcr)) ||
139130

api/src/Controllers/UserController.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,8 @@ function _update_user()
275275
$person = $this->userData->getUser($this->user->personId, $this->proposalid, $this->arg('PERSONID'));
276276
$person = $person[0];
277277
$this->_output((array) $person);
278-
$laboratory = null;
279-
if ($person['LABORATORYID'])
280-
{
281-
$laboratory = $this->userData->getLaboratory($person['LABORATORYID'])[0];
282-
}
283278

284-
$this->userData->updateLaboratory(
279+
$laboratoryId = $this->userData->updateLaboratory(
285280
$this->arg('PERSONID'),
286281
$this->argOrNull('LABNAME'),
287282
$this->argOrNull('ADDRESS'),
@@ -290,7 +285,7 @@ function _update_user()
290285
$this->argOrNull('COUNTRY'),
291286
$person['LABORATORYID']
292287
);
293-
$laboratory = $this->userData->getLaboratory($person['LABORATORYID']);
288+
$laboratory = $this->userData->getLaboratory($laboratoryId);
294289
$this->_output((array) $laboratory[0]);
295290
}
296291

@@ -362,4 +357,4 @@ function _update_permission()
362357
);
363358
$this->_output(array('TYPE' => $this->arg('TYPE'), 'DESCRIPTION' => $desc));
364359
}
365-
}
360+
}

api/src/Model/Services/UserData.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ function updateLaboratory($personId, $labName, $labAddress, $city, $postcode, $c
340340
->whereIdEquals("personid", $personId)
341341
->update("person");
342342
}
343+
return $laboratoryId;
343344
}
344345

345346
function addGroupUser($personId, $gid)

api/src/Page.php

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -222,29 +222,8 @@ function auth($require_staff)
222222
{
223223
$auth = $this->staff;
224224

225-
// Beamline Sample Registration
226-
}
227-
else if ($this->blsr() && !$this->user->loginId)
228-
{
229-
$auth = false;
230-
231-
if ($this->has_arg('visit'))
232-
{
233-
$blsr_visits = array();
234-
foreach ($this->blsr_visits() as $v)
235-
array_push($blsr_visits, $v['VISIT']);
236-
237-
if (in_array($this->arg('visit'), $blsr_visits))
238-
$auth = True;
239-
240-
}
241-
else
242-
{
243-
$auth = true;
244-
}
245-
246-
// Barcode Scanners
247225
}
226+
// Barcode Scanners
248227
else if ($this->bcr() && !$this->user->loginId)
249228
{
250229
$auth = true;
@@ -761,42 +740,6 @@ function pro()
761740
}
762741

763742

764-
# ------------------------------------------------------------------------
765-
# Beamline sample registration: Get Beamline from IP
766-
function ip2bl()
767-
{
768-
global $ip2bl;
769-
$parts = explode('.', $_SERVER['REMOTE_ADDR']);
770-
771-
if ($parts && sizeof($parts) > 1 && array_key_exists($parts[2], $ip2bl))
772-
{
773-
return $ip2bl[$parts[2]];
774-
}
775-
}
776-
777-
778-
# Return visit list for blsr;
779-
function blsr_visits()
780-
{
781-
$b = $this->ip2bl();
782-
783-
if (!$b)
784-
return array();
785-
786-
$visits = $this->db->pq("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE TIMESTAMPDIFF('DAY', s.startdate, CURRENT_TIMESTAMP) < 1 AND TIMESTAMPDIFF('DAY', CURRENT_TIMESTAMP, s.enddate) < 2 AND s.beamlinename LIKE :1 ORDER BY s.startdate", array($b));
787-
$v = $this->db->paginate("SELECT CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit, TO_CHAR(s.startdate, 'DD-MM-YYYY HH24:MI') as st, TO_CHAR(s.enddate, 'DD-MM-YYYY HH24:MI') as en,s.beamlinename as bl FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE p.proposalcode LIKE 'cm' AND s.beamlinename LIKE :1 AND s.enddate <= CURRENT_TIMESTAMP ORDER BY s.startdate DESC", array($b, 0, 1));
788-
$visits = array_merge($visits, $v);
789-
return $visits;
790-
}
791-
792-
# Beamline Sample Registration Machine
793-
function blsr()
794-
{
795-
global $blsr;
796-
797-
return in_array($_SERVER['REMOTE_ADDR'], $blsr);
798-
}
799-
800743
# Barcode Scanner Machines
801744
function bcr()
802745
{
@@ -1093,9 +1036,9 @@ function get_visit_processed_dir($dc, $location)
10931036

10941037
function _submit_zocalo_recipe($recipe, $parameters, $error_code = 500)
10951038
{
1096-
global $zocalo_mx_reprocess_queue;
1039+
global $rabbitmq_zocalo_vhost;
10971040

1098-
if (isset($zocalo_mx_reprocess_queue))
1041+
if (isset($rabbitmq_zocalo_vhost))
10991042
{
11001043
// Send job to processing queue
11011044
$zocalo_message = array(
@@ -1104,7 +1047,7 @@ function _submit_zocalo_recipe($recipe, $parameters, $error_code = 500)
11041047
),
11051048
'parameters' => $parameters,
11061049
);
1107-
$this->_send_zocalo_message($zocalo_mx_reprocess_queue, $zocalo_message, $error_code);
1050+
$this->_send_zocalo_message($rabbitmq_zocalo_vhost, $zocalo_message, $error_code);
11081051
}
11091052
}
11101053

@@ -1130,7 +1073,6 @@ function _send_zocalo_message($rabbitmq_zocalo_vhost, $zocalo_message, $error_co
11301073

11311074
try
11321075
{
1133-
error_log("Sending message" . var_export($zocalo_message, true));
11341076
$queue = new Queue($rabbitmq_zocalo_host, $rabbitmq_zocalo_port, $rabbitmq_zocalo_username, $rabbitmq_zocalo_password, $rabbitmq_zocalo_vhost);
11351077
$queue->send($zocalo_message, $rabbitmq_zocalo_routing_key);
11361078
}

api/src/Page/Image.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ class Image extends Page
2020
'aid' => '\d+',
2121
'visit' => '\w+\d+-\d+',
2222
'thresh' => '\d',
23+
'res' => '\d',
24+
'ice' => '\d',
2325
);
2426

2527
public static $dispatch = array(array('/id/:id(/n/:n)', 'get', '_xtal_image'),
2628
array('/diff/id/:id(/f/:f)(/n/:n)', 'get', '_diffraction_image'),
27-
array('/di/id/:id(/thresh/:thresh)(/n/:n)', 'get', '_diffraction_viewer'),
29+
array('/di/id/:id(/thresh/:thresh)(/res/:res)(/ice/:ice)(/n/:n)', 'get', '_diffraction_viewer'),
2830
array('/cam/bl/:bl(/n/:n)', 'get', '_forward_webcam'),
2931
array('/oav/bl/:bl(/n/:n)', 'get', '_forward_oav'),
3032
array('/fa/fid/:id', 'get', '_fault_attachment'),
@@ -192,7 +194,7 @@ function _diffraction_viewer() {
192194
}
193195

194196
$im = $info['LOC'] . '/' . $info['FT'];
195-
$out = '/tmp/' . $this->arg('id') . '_' . $n . ($this->has_arg('thresh') ? '_th' : '') . '.jpg';
197+
$out = '/tmp/' . $this->arg('id') . '_' . $n . ($this->has_arg('thresh') ? '_th' : '') . ($this->has_arg('res') ? '_res' : '') . ($this->has_arg('ice') ? '_ice' : '') . '.jpg';
196198
global $dials_rest_url, $dials_rest_jwt;
197199
if (!file_exists($out)) {
198200
if (!empty($dials_rest_url) && !empty($dials_rest_jwt)) {
@@ -212,6 +214,8 @@ function _diffraction_viewer() {
212214
'colour_scheme' => 'greyscale',
213215
'brightness' => $this->has_arg('thresh') ? 1000 : 10,
214216
'format' => 'png',
217+
'resolution_rings' => array('show' => $this->has_arg('res')),
218+
'ice_rings' => array('show' => $this->has_arg('ice')),
215219
)
216220
));
217221
} else {

api/src/Page/Proposal.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,8 @@ function _update_autocollect_session($sessionId, $uasSessionId, $containerId, $t
12051205
$uas = new UAS($auto_user, $auto_pass);
12061206
$code = $uas->update_session($uasSessionId, $data);
12071207

1208-
if ($code == 200) {
1209-
// Update ISPyB records
1208+
if ($code == 200 || $code == 404) {
1209+
// Update ISPyB records, even if UAS says session not found
12101210
$this->db->pq("UPDATE container SET sessionid=:1 WHERE containerid=:2", array($sessionId, $containerId));
12111211
// For debugging - actually just want to return Success!
12121212
$result = array(
@@ -1216,13 +1216,11 @@ function _update_autocollect_session($sessionId, $uasSessionId, $containerId, $t
12161216
);
12171217
} else if ($code == 403) {
12181218
$this->_error('UAS Error - samples and/or investigators not valid. ISPyB/UAS Session ID: ' . $sessionId . ' / ' . $uasSessionId);
1219-
} else if ($code == 404) {
1220-
$this->_error('UAS Error - session not found in UAS, Session ID: ' . $sessionId . ' UAS Session ID: ' . $uasSessionId);
12211219
} else {
1222-
$this->_error('UAS Error - something wrong creating a session for that container ' . $containerId . ', response code was: ' . $code);
1220+
$this->_error('UAS Error - something went wrong updating a session for that container ' . $containerId . ', response code was: ' . $code);
12231221
}
12241222
} else {
1225-
error_log("Something wrong - an Auto Collect session exists but with no containers " . $sessionId);
1223+
error_log("Something went wrong - an Auto Collect session exists but with no containers " . $sessionId);
12261224

12271225
$this->_error('No valid containers on the existing Auto Collect Session id:', $sessionId);
12281226
}

0 commit comments

Comments
 (0)