Skip to content

Commit

Permalink
Merge pull request #11 from FNNDSC/10-multi-analysis-support
Browse files Browse the repository at this point in the history
10 multi analysis support
  • Loading branch information
Sandip117 authored Dec 12, 2023
2 parents 5a320f3 + 291dfda commit 456271f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 23 deletions.
19 changes: 13 additions & 6 deletions pfbridge/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ class Pflink(BaseSettings):
testURL:str = 'http://localhost:8050/api/v1/testing'
ignore_duplicate:bool = True


class Analyses(BaseSettings):
analyses: dict = {}

class DylldAnalysis(Pflink):
pipelineName:str = ''
pluginName:str = 'pl-dylld'
pluginVersion:str = '4.4.28'
pluginArgs:str = '--pattern **/*dcm --CUBEurl %urlCUBE --CUBEuser %usernameCUBE --CUBEpassword %passwordCUBE --orthancURL %urlOrthanc --orthancuser %usernameOrthanc --orthancpassword %passwordOrthanc'
feedName:str = 'dylld-%SeriesInstanceUID'
pluginName:str = ''
pluginVersion:str = ''
pluginArgs:str = ''
feedName:str = 'pfbridge-%SeriesInstanceUID'

class PflinkAuth(Pflink):
pflink_auth_url:str = "http://localhost:8050/api/v1/auth-token"
Expand Down Expand Up @@ -48,7 +52,7 @@ def vaultCheckLock(vault:Vault) -> None:
vault.locked = True
print("Vault check: key has already been set. Vault is now LOCKED.")

def analysis_decode() -> None:
def analysis_decode(key:str) -> None:
decode:pftag.Pftag = pftag.Pftag({})
addDict:bool = decode.lookupDict_add(
[
Expand All @@ -74,7 +78,7 @@ def analysis_decode() -> None:
]
)
for field in ["pluginArgs", "pipelineName", "pluginName", "feedName", "pluginVersion"]:
d_decode:dict = decode(analysis.__getattribute__(field))
d_decode:dict = decode(analyses.analyses[key].__getattribute__(field))
analysisDecoded.__setattr__(field, d_decode["result"])

pflink = Pflink()
Expand All @@ -86,4 +90,7 @@ def analysis_decode() -> None:
serviceURLs = ServiceURLs()
pflinkAuth = PflinkAuth()
pfdcm = Pfdcm()
analyses = Analyses()
analyses.analyses["dylld"] = analysisDecoded


13 changes: 6 additions & 7 deletions pfbridge/lib/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ def intoPflink_transform(self, payload:relayModel.clientPayload) -> relayModel.p
pflinkPOST.workflow_info.feed_name = settings.analysis.feedName
pflinkPOST.cube_user_info.username = settings.credentialsCUBE.usernameCUBE
pflinkPOST.cube_user_info.password = settings.credentialsCUBE.passwordCUBE
match payload.analyzeFunction:
case 'dylld':
pflinkPOST.workflow_info.pipeline_name = settings.analysis.pipelineName
pflinkPOST.workflow_info.plugin_name = settings.analysis.pluginName
pflinkPOST.workflow_info.plugin_version = settings.analysis.pluginVersion
settings.analysis_decode()
pflinkPOST.workflow_info.plugin_params = settings.analysisDecoded.pluginArgs
if settings.analyses.analyses.get(payload.analyzeFunction):
pflinkPOST.workflow_info.pipeline_name = settings.analyses.analyses[payload.analyzeFunction].pipelineName
pflinkPOST.workflow_info.plugin_name = settings.analyses.analyses[payload.analyzeFunction].pluginName
pflinkPOST.workflow_info.plugin_version = settings.analyses.analyses[payload.analyzeFunction].pluginVersion
settings.analysis_decode(payload.analyzeFunction)
pflinkPOST.workflow_info.plugin_params = settings.analysisDecoded.pluginArgs
return pflinkPOST

def fromPflink_transform(self, payload:httpx.Response) -> relayModel.clientResponseSchema:
Expand Down
3 changes: 3 additions & 0 deletions pfbridge/lib/pflinkclient.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
This class contains useful methods to authenticate and re/generate auth tokens for `pflink`
"""
import httpx

class Client(object):
Expand Down
2 changes: 1 addition & 1 deletion pfbridge/models/relayModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class PACSqueryCore(BaseModel):
AcquisitionProtocolName : str = ""

class analysisModel(BaseModel):
feed_name:str = settings.analysis.feedName
feed_name:str = ""
plugin_name:str = ""
plugin_version:str = ""
plugin_params:str = ""
Expand Down
24 changes: 15 additions & 9 deletions pfbridge/routes/relayRouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def urlOrthanc_update(URL:str) -> relayModel.serviceURLs:
'''
)
def analysis_update(
analysis_name = '',
key = '',
value = ''
) -> settings.DylldAnalysis:
Expand All @@ -299,18 +300,20 @@ def analysis_update(
-------
* `settings.Analysis`: The current Analysis settings
"""
if not settings.analyses.analyses.get(analysis_name):
settings.analyses.analyses[analysis_name] = settings.DylldAnalysis()
match key:
case 'analysisPipelineName':
settings.analysis.pipelineName = value
settings.analyses.analyses[analysis_name].pipelineName = value
case 'analysisPluginName':
settings.analysis.pluginName = value
settings.analyses.analyses[analysis_name].pluginName = value
case 'analysisPluginArgs':
settings.analysis.pluginArgs = value
settings.analyses.analyses[analysis_name].pluginArgs = value
case 'analysisPluginVersion':
settings.analysis.pluginVersion = value
settings.analyses.analyses[analysis_name].pluginVersion = value
case 'analysisFeedName':
settings.analysis.feedName = value
return settings.analysis
settings.analyses.analyses[analysis_name].feedName = value
return settings.analyses.analyses[analysis_name]

@router.get(
'/analysis/',
Expand All @@ -319,7 +322,7 @@ def analysis_update(
GET the internal Analysis settings.
'''
)
def analysisValues_get(vaultKey:str = "") -> settings.DylldAnalysis:
def analysisValues_get(vaultKey:str = "", analysis_name:str = "") -> settings.DylldAnalysis:
"""
Description
-----------
Expand All @@ -332,12 +335,15 @@ def analysisValues_get(vaultKey:str = "") -> settings.DylldAnalysis:
-------
* `settings.Analysis`: The current Analysis settings
"""
values:settings.DylldAnalysis = settings.analysis
if settings.analyses.analyses.get(analysis_name):
values:settings.DylldAnalysis = settings.analyses.analyses[analysis_name]
else:
values:settings.DylldAnalysis = settings.analysis
if vaultKey:
d_vaultAccess:credentialModel.credentialsStatus = credentialModel.credentialsStatus()
d_vaultAccess = credentialRouter.credentialAccess_check(vaultKey)
if d_vaultAccess.status:
settings.analysis_decode()
settings.analysis_decode(analysis_name)
values = settings.analysisDecoded
return values

Expand Down

0 comments on commit 456271f

Please sign in to comment.