Skip to content

Commit

Permalink
Merge pull request #33 from FNNDSC/error-logging
Browse files Browse the repository at this point in the history
Error logging
  • Loading branch information
Sandip117 committed Aug 3, 2023
2 parents 8bb9329 + 59e04c1 commit 37deaba
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class Settings(BaseSettings):
pflink_mongodb: MongoDsn = 'mongodb://localhost:27017'
version: str = "3.5.4"
version: str = "3.6.0"


class Auth(BaseSettings):
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from fastapi.security import OAuth2PasswordBearer
from pydantic import ValidationError

ACCESS_TOKEN_EXPIRE_MINUTES = 600 # 600 minutes
ACCESS_TOKEN_EXPIRE_MINUTES = 600 # minutes to expire
ALGORITHM = "HS256"
JWT_SECRET_KEY = auth.JWT_SECRET_KEY

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/pfdcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ async def cube_list(service_name: str) -> list[str]:
return d_results


# Get the list of `swift` servers available in a pfdcm instance
async def swift_list(service_name: str) -> list[str]:
# Get the list of `storage` services available in a pfdcm instance
async def storage_list(service_name: str) -> list[str]:
d_results = []
pfdcm_server = retrieve_pfdcm(service_name)
if not pfdcm_server:
return d_results
pfdcm_url = pfdcm_server['service_address']
pfdcm_swift_list_api = f'{pfdcm_url}/SMDB/swift/list/'
pfdcm_storage_list_api = f'{pfdcm_url}/SMDB/storage/list/'
async with httpx.AsyncClient() as client:
try:
response = await client.get(pfdcm_swift_list_api)
response = await client.get(pfdcm_storage_list_api)
d_results = json.loads(response.text)
return d_results
except:
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/subprocesses/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def _get_feed_status(request: WorkflowRequestSchema, feed_id: str) -> dict:

# search for feed
resp = cl.getFeed({"id": feed_id, "name_exact": feed_name})
if resp["errored_jobs"] or resp["cancelled_jobs"]:
l_inst_resp = cl.getPluginInstances({"feed_id": feed_id})
l_error = [d_instance['plugin_name'] for d_instance in l_inst_resp['data'] if d_instance['status']=='finishedWithError' or d_instance['status'] == 'cancelled']
resp["errored_plugins"] = str(l_error)
return resp
except Exception as ex:
return {"error": Error.cube.value + str(ex)}
Expand Down Expand Up @@ -230,7 +234,7 @@ def get_analysis_status(response: dict) -> dict:
analysis_details['progress'] = str(feed_progress) + "%"

if errored > 0 or cancelled > 0:
analysis_details["error"] = str(errored + cancelled) + " job(s) failed"
analysis_details["error"] = f"{(errored + cancelled)} job(s) failed : {response['errored_plugins']}"
if feed_progress == 100:
analysis_details["state"] = State.COMPLETED
else:
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/subprocesses/wf_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def manage_workflow(db_key: str, test: bool):
try:
do_cube_start_analysis(pl_inst_id, request, cube_url)
except Exception as ex:
logging.info(Error.analysis.value)
logging.info(Error.analysis.value + str(ex))
workflow.response.error = Error.analysis.value + str(ex)
workflow.response.status = False
update_workflow(key, workflow)
Expand Down
6 changes: 3 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
* **Get a `hello` response from a pfdcm instance.**
* **Know `about` a pfdcm instance.**
* **Get the list of the names of all `cube` instances available in a pfdcm instance.**
* **Get the list of the names of all `swift` instances available in a pfdcm instance.**
* **Get the list of the names of all `PACS` instances available in a pfdcm instance.**
* **Get the list of the names of all `cube` services available in a pfdcm instance.**
* **Get the list of the names of all `storage` services available in a pfdcm instance.**
* **Get the list of the names of all `PACS` services available in a pfdcm instance.**
## Workflow
Expand Down
14 changes: 7 additions & 7 deletions app/routes/pfdcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def get_about_pfdcm(service_name: str) -> PfdcmQueryResponseSchema:
)
async def cube_service_list(service_name: str) -> list[str]:
"""
Get the list of PACS services registered to a `pfdcm` instance by providing its service name
Get the list of CUBE services registered to a `pfdcm` instance by providing its service name
"""
response = await pfdcm.cube_list(service_name)
if not response:
Expand All @@ -101,15 +101,15 @@ async def cube_service_list(service_name: str) -> list[str]:


@router.get(
"/{service_name}/swift/list",
"/{service_name}/storage/list",
response_description="About PFDCM",
summary="Get the list of swift services registered to a `pfdcm` instance"
summary="Get the list of storage services registered to a `pfdcm` instance"
)
async def swift_service_list(service_name: str) -> list[str]:
async def storage_service_list(service_name: str) -> list[str]:
"""
Get the list of PACS services registered to a `pfdcm` instance by providing its service name
Get the list of storage services registered to a `pfdcm` instance by providing its service name
"""
response = await pfdcm.swift_list(service_name)
response = await pfdcm.storage_list(service_name)
if not response:
raise HTTPException(status_code=404, detail=f"Unable to reach endpoints of {service_name}")
return response
Expand All @@ -136,4 +136,4 @@ async def delete_pfdcm(service_name: str):
Delete a pfdcm record from the DB
"""
response = await pfdcm.delete_pfdcm(service_name)
return response
return response
9 changes: 9 additions & 0 deletions app/routes/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ async def create_workflow(data: WorkflowRequestSchema) -> WorkflowStatusResponse
return response


@router.get("/list", response_description="All workflows retrieved")
async def get_workflows():
"""
Fetch all workflows currently present in the database
"""
workflows = workflow.retrieve_workflows()
return workflows


@router.delete("", response_description="All workflows deleted")
async def delete_workflows():
"""
Expand Down

0 comments on commit 37deaba

Please sign in to comment.