Skip to content

Commit

Permalink
Merge branch 'release/2024.1.x' into ACAS-744
Browse files Browse the repository at this point in the history
  • Loading branch information
brianbolt committed Feb 5, 2024
2 parents 8f1c8ce + 5672f10 commit fc0cf70
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 33 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Docker Image CI
on:
push:
branches: ["master", "release/*"]
tags:
- "*"
pull_request:
types: [opened, synchronize]
create:
tags: "**"
jobs:
acas:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -61,13 +61,15 @@ jobs:
# Check out the branch specified by ACAS_CLIENT_REF
ref: ${{ env.ACAS_CLIENT_REF }}
- name: Build (no push)
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
push: false
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ env.ACAS_TAG }}
Expand Down Expand Up @@ -110,15 +112,18 @@ jobs:
pip install ./acasclient
- name: Run tests
run: python -m unittest discover -s ./acasclient -p "test_*.py" -v
- name: Build and push
uses: docker/build-push-action@v3
- name: Build multi-arch and push
# Only push tags and release branches
if: ${{ startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/') }}
uses: docker/build-push-action@v5
with:
# Only push tags and release branches
push: ${{ startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/') }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile
platforms: linux/amd64,linux/arm64/v8
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ env.ACAS_TAG }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN dnf install -y initscripts python3-psycopg2

# node
ENV NPM_CONFIG_LOGLEVEL warn
ENV NODE_VERSION 14.x
ENV NODE_VERSION 18.x
RUN curl -fsSL https://rpm.nodesource.com/setup_$NODE_VERSION | bash - && \
dnf install -y nodejs

Expand Down
11 changes: 10 additions & 1 deletion conf/config.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@ server.sel.protocolStatus=created
server.sel.assayStage=unassigned
server.sel.validateDoseResponseCurves=true

# Default protocol/experiment description when loaded through experiment loader
# server.sel.protocolDescription=${client.protocol.label} created by generic data parser
# server.sel.experimentDescription=${client.experiment.label} created by generic data parser
server.sel.protocolDescription=
server.sel.experimentDescription=

# Cron- change to "false" to not start cron jobs on startup
server.service.cron.startOnRestart=true
server.service.cron.enable=true
Expand Down Expand Up @@ -631,6 +637,9 @@ server.systemTest.runDestructive=false
# Behavior without this config set to true is to give all users access to all projects
server.project.roles.enable=true

# Require project type to be returned by project CustomerSpecificFunctions
server.project.type.required=false

#Controls whether to try to sync projects list from ACAS to CmpdReg
server.project.sync.cmpdReg=true

Expand Down Expand Up @@ -710,7 +719,7 @@ client.cmpdreg.metaLot.requireLotNumber=false
client.cmpdreg.metaLot.allowManualLotNumber=false
client.cmpdreg.metaLot.autoPopulateNextLotNumber=true
client.cmpdreg.metaLot.maxAutoLotNumber=1000
client.cmpdreg.metaLot.allowDuplicateParentAliases=true
client.cmpdreg.metaLot.allowDuplicateParentAliases=false
client.cmpdreg.serverSettings.corpPrefix=CMPD
client.cmpdreg.serverSettings.corpSeparator=-
client.cmpdreg.serverSettings.saltSeparator=
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
- logs:/home/runner/logs
command: ["bin/acas.sh", "run", "rservices"]
db:
image: mcneilco/acas-postgres:release-1.13.7
image: mcneilco/acas-postgres:release-2023.3.x
restart: always
volumes:
- dbstore:/var/lib/postgresql/data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exports.applicationScripts = [
'/javascripts/src/Components/ACASFormStateTable.js',
'/javascripts/src/Components/BasicFileValidateAndSave.js',
'/javascripts/src/Components/BasicFileValidateReviewAndSave.js',
'/javascripts/src/Components/BasicThingValidateAndSave.js',
'/javascripts/src/Components/ACASThingBrowser.js',
'/javascripts/src/Components/PickList.js',
'/javascripts/src/CodeTablesAdmin/AbstractCodeTable.js',
Expand Down
4 changes: 2 additions & 2 deletions modules/CmpdReg/src/server/routes/CmpdRegRoutes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ exports.setupRoutes = (app, loginRoutes) ->
app.post '/cmpdReg/api/v1/structureServices/hydrogenizer', loginRoutes.ensureAuthenticated, exports.genericStructureService
app.post '/cmpdReg/api/v1/structureServices/cipStereoInfo', loginRoutes.ensureAuthenticated, exports.genericStructureService
app.post '/cmpdReg/export/searchResults', loginRoutes.ensureAuthenticated, exports.exportSearchResults
app.post '/cmpdReg/validateParent', loginRoutes.ensureAuthenticated, loginRoutes.ensureCmpdRegAdmin, exports.validateParent
app.post '/cmpdReg/updateParent', loginRoutes.ensureAuthenticated, loginRoutes.ensureCmpdRegAdmin, exports.updateParent
app.post '/cmpdReg/validateParent', loginRoutes.ensureAuthenticated, exports.validateParent
app.post '/cmpdReg/updateParent', loginRoutes.ensureAuthenticated, exports.updateParent
app.post '/cmpdReg/swapParentStructures', loginRoutes.ensureAuthenticated, loginRoutes.ensureCmpdRegAdmin, exports.swapParentStructures
app.post '/cmpdReg/api/v1/lotServices/update/lot/metadata', loginRoutes.ensureAuthenticated, exports.updateLotMetadata
app.post '/cmpdReg/api/v1/lotServices/update/lot/metadata/jsonArray', loginRoutes.ensureAuthenticated, exports.updateLotsMetadata
Expand Down
64 changes: 52 additions & 12 deletions modules/GenericDataParser/src/server/generic_data_parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -706,27 +706,58 @@ validateCalculatedResults <- function(calculatedResults, dryRun, curveNames, tes
# A project can only be used in the experiment if it's an unrestricted project or belongs to the project which this experiment belongs to
projectsDT <- data.table(projectDF)

# Loop through by project code and create a projectAllowedForExperiment column
# Add project type if its missing
if(!"type" %in% colnames(projectsDT)) {
projectsDT[ , type := NA]
}

# Get the project type of the experiment project if required by configurations
projectType <- NA
if(configList$server.project.type.required) {
projectType <- projectsDT[code == projectCode]$type
if(is.na(projectType)) {
stopUser(paste0("Project '",projectCode,"' does not have a type. Please contact your system administrator."))
}
}

# Here we are annotating each of the projects with a boolean as to whether it can be used in the experiment if its used by a lot
projectsDT[ , projectAllowedForExperiment := {
# Check if the project is unrestricted or if it equals the projectCode of the experiment
!isRestricted | code == projectCode
# projectType and projectCode are referring to the experiment project
# type, code, and isRestricted are referring to the batch project
if(is.na(projectType)) {
# If the project type is na then this is not a system with project type
# so we just check if the project is restricted and if the lot project is the same as the experiment project
!isRestricted | code == projectCode
} else {
# If project type is not na then this is a system with project type
switch(projectType,
"RESTRICTED" = !isRestricted | code == projectCode,
"HYPER_RESTRICTED" = code == projectCode,
"UNRESTRICTED" = ifelse(identical(type, "HYPER_RESTRICTED"), FALSE, TRUE),
"GLOBAL" = ifelse(identical(type, "HYPER_RESTRICTED"), FALSE, TRUE),
stopUser(paste0("Project '",projectCode,"' has an invalid type. Please contact your system administrator."))
)
}

}, by = code]

# Merge batch projects to project restrition information
batchProjectWithRestrictionInfo <- as.data.table(merge(batchProjects, projectsDT, by.x="Project.Code", by.y="code"))

# Create a data table with one row per batch with a boolean column as to whether it can be used in the experiment
# if any of the projects the batch belongs to is allowed to be loaded to this experiment, then the batch can be loaded to the experiment
canUseBatchDT <- batchProjectWithRestrictionInfo[ , any(projectAllowedForExperiment), by = Requested.Name]
canUseBatchDT <- batchProjectWithRestrictionInfo[ , any(projectAllowedForExperiment), by = c("Requested.Name", "type")]
setnames(canUseBatchDT, "V1", "batchCanBeLoadedToExperimentProject")

# Get a list of batches which are restricted and cannot be used in this experiment's project
rCompounds <- canUseBatchDT[batchCanBeLoadedToExperimentProject == FALSE]$Requested.Name
rCompounds <- canUseBatchDT[batchCanBeLoadedToExperimentProject == FALSE]

if (length(rCompounds) > 0) {
if (nrow(rCompounds) > 0) {
addProjectError <- TRUE
shouldCheckRole <- configList$server.project.roles.enable & !is.null(configList$client.roles.crossProjectLoaderRole)
if(shouldCheckRole) {
crossProjectLoaderRolesEnabled <- configList$server.project.roles.enable & !is.null(configList$client.roles.crossProjectLoaderRole)
# HYPER_RESTRICTED projects are not allowed to be loaded to other projects by anyone
# So only check cross project loader roles if the project is not HYPER_RESTRICTED
if(crossProjectLoaderRolesEnabled && !identical(projectType, "HYPER_RESTRICTED")) {
response <- getURL(URLencode(paste0(racas::applicationSettings$server.nodeapi.path, racas::applicationSettings$client.service.users.path, "/", user)))
if(response=="") {
addError(paste0("Username '",user,"' could not be found in the system"))
Expand All @@ -740,8 +771,17 @@ validateCalculatedResults <- function(calculatedResults, dryRun, curveNames, tes
}
}
if(addProjectError) {
addError(paste0("Compounds '", paste(rCompounds, collapse = "', '"),
# Return error message for each type of project
# if projectType (experiment project) is restricted then return error message for specific for hyper restrictions
rCompounds[ , {
if(identical(projectType, "HYPER_RESTRICTED")) {
addError(paste0("Compounds '", paste(.SD$Requested.Name, collapse = "', '"),
"' are in a project that does not match the hyper restricted project entered for this ",racas::applicationSettings$client.experiment.label,"."))
} else {
addError(paste0("Compounds '", paste(.SD$Requested.Name, collapse = "', '"),
"' are in a restricted project that does not match the one entered for this ",racas::applicationSettings$client.experiment.label,"."))
}
}, by = type]
}
}
}
Expand Down Expand Up @@ -2106,7 +2146,7 @@ createNewProtocol <- function(metaData, lsTransaction, recordedBy, columnOrderSt

# Create the protocol
protocol <- createProtocol(lsTransaction = lsTransaction,
shortDescription=paste0(racas::applicationSettings$client.protocol.label," created by generic data parser"),
shortDescription=racas::applicationSettings$server.sel.protocolDescription,
recordedBy=recordedBy,
protocolLabels=protocolLabels,
protocolStates=protocolStates)
Expand Down Expand Up @@ -2273,7 +2313,7 @@ createNewExperiment <- function(metaData, protocol, lsTransaction, pathToGeneric
shortDescription = if(!is.null(metaData$"Short Description"[1])) {
metaData$"Short Description"[1]
} else {
paste0(racas::applicationSettings$client.experiment.label," created by generic data parser")
racas::applicationSettings$server.sel.experimentDescription
},
recordedBy=recordedBy,
experimentLabels=experimentLabels,
Expand Down
20 changes: 18 additions & 2 deletions modules/ServerAPI/src/client/SaltBrowser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,15 @@ class SaltBrowserController extends Backbone.View
console.log(errorMsg)
@$('.bv_createSalt').hide()
@$('.bv_errorCreatingSaltMessage').show()
@$('.bv_createSaltErrorMessageHolder') errorMsg
errorData = JSON.parse(errorMsg.responseText)
errorContainer = @$('.bv_createSaltErrorMessageHolder')
errorContainer.empty()
errorContainer.append("<p>Error(s):</p>")
errorList = $('<ul class="error-list"></ul>')
for error in errorData
errorMessage = error.message
errorList.append("<li>#{errorMessage}</li>")
errorContainer.append(errorList)
)

handleBackConfirmCreateClicked: =>
Expand Down Expand Up @@ -392,7 +400,15 @@ class SaltBrowserController extends Backbone.View
console.log(errorMsg)
@$('.bv_confirmCreateSalt').hide()
@$('.bv_errorCreatingSaltMessage').show()
@$('.bv_createSaltErrorMessageHolder') errorMsg
errorData = JSON.parse(errorMsg.responseText)
errorContainer = @$('.bv_createSaltErrorMessageHolder')
errorContainer.empty()
errorContainer.append("<p>Error(s):</p>")
errorList = $('<ul class="error-list"></ul>')
for error in errorData
errorMessage = error.message
errorList.append("<li>#{errorMessage}</li>")
errorContainer.append(errorList)
@$('.bv_createNotifications').hide()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ exports.getProjectStubsInternal = (callback) ->
#remove groups attribute
_.each acasGroupsAndProjects.projects, (project) ->
delete project.groups
# ACAS-754: Adding project type to project object
# This is for testing experiment loader with different project types explained in ACAS-754
# if project.name == "Global"
# project.type = "GLOBAL"
# else if project.isRestricted
# project.type = "HYPER_RESTRICTED"
# else
# project.type = "UNRESTRICTED"
callback response.statusCode, acasGroupsAndProjects.projects

exports.makeServiceRequestHeaders = (user) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
from ldclient.api.requester import SUPPORTED_SERVER_VERSION
from ldclient.base import version_str_as_tuple

# Prior to Live Design 2024-1, ProjectType was not available in the API
# so we only import it and use it if it is available in order to maintain backwards compatibility
try:
from ldclient.enums import ProjectType
except ImportError:
ProjectType = None

import argparse
import json
import os, sys
Expand Down Expand Up @@ -268,15 +275,28 @@ def get_projects(client):
return projects

def ld_project_to_acas(ld_project):

# Prior to Live Design 2024-1, the project type was not available in the API
# so we only set it if it is available in order to maintain backwards compatibility
if ProjectType is not None:
project_acls = {
'isRestricted': ld_project.project_type not in (ProjectType.GLOBAL, ProjectType.UNRESTRICTED),
'type': ld_project.project_type
}
else:
project_acls = {
'isRestricted': ld_project.restricted
}

acas_project = {
'id': ld_project.id,
'code': ld_project.name,
'alias': ld_project.name,
'active': True if ld_project.active == "Y" else False,
'ignored': False if ld_project.active == "Y" else True,
'isRestricted': ld_project.restricted,
'name': ld_project.name
}
acas_project.update(project_acls)
return acas_project

def main():
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
"errorhandler": "^1.5.1",
"express": "^4.17.1",
"express-session": "^1.17.1",
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "6.2.0",
"flat": "5.0.2",
"forever-monitor": "3.0.3",
"glob": "7.1.6",
Expand All @@ -43,18 +41,18 @@
"jasmine-jquery": "^2.1.1",
"jquery": "^3.5.1",
"json2csv": "^5.0.5",
"jszip": "3.5.0",
"jszip": "3.10.1",
"less": "^3.12.2",
"lodash": "^4.17.20",
"marked": "1.2.5",
"marked": "4.0.10",
"memorystore": "1.6.4",
"method-override": "^3.0.0",
"mocha": "8.2.1",
"mochawesome": "^6.2.1",
"mongojs": "3.1.0",
"morgan": "^1.10.0",
"multer": "^1.4.2",
"node-fetch": "3.2.6",
"node-fetch": "3.2.10",
"ncp": "2.0.0",
"passport": "0.6.0",
"passport-local": "1.0.0",
Expand All @@ -71,7 +69,7 @@
"socket.io": "2.4.1",
"style-loader": "2.0.0",
"temporary": "1.1.0",
"underscore": "1.12.0",
"underscore": "1.12.1",
"underscore-deep-extend": "1.1.5",
"url-loader": "4.1.1",
"winston": "3.3.3",
Expand Down

0 comments on commit fc0cf70

Please sign in to comment.