Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACAS-712: HRP project type support #1138

Merged
merged 14 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions conf/config.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -637,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

brianbolt marked this conversation as resolved.
Show resolved Hide resolved
#Controls whether to try to sync projects list from ACAS to CmpdReg
server.project.sync.cmpdReg=true

Expand Down
60 changes: 50 additions & 10 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
brianbolt marked this conversation as resolved.
Show resolved Hide resolved
if(is.na(projectType)) {
stopUser(paste0("Project '",projectCode,"' does not have a type. Please contact your system administrator."))
brianbolt marked this conversation as resolved.
Show resolved Hide resolved
}
}

# 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
# code and isRestricted are referring to the batch project
brianbolt marked this conversation as resolved.
Show resolved Hide resolved
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
brianbolt marked this conversation as resolved.
Show resolved Hide resolved
} 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."))
)
brianbolt marked this conversation as resolved.
Show resolved Hide resolved
}

}, 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")]
brianbolt marked this conversation as resolved.
Show resolved Hide resolved
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]
brianbolt marked this conversation as resolved.
Show resolved Hide resolved

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
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
brianbolt marked this conversation as resolved.
Show resolved Hide resolved
# For testing purposes only
# 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 @@ -5,6 +5,7 @@
from ldclient.client import LDClient
from ldclient.api.requester import SUPPORTED_SERVER_VERSION
from ldclient.base import version_str_as_tuple
from ldclient.enums import ProjectType
brianbolt marked this conversation as resolved.
Show resolved Hide resolved

import argparse
import json
Expand Down Expand Up @@ -274,7 +275,7 @@ def ld_project_to_acas(ld_project):
'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,
'isRestricted': ld_project.project_type not in (ProjectType.GLOBAL, ProjectType.UNRESTRICTED),
'name': ld_project.name
}
return acas_project
Expand Down