bcgsc / pori_python

GNU General Public License v3.0
0 stars 1 forks source link

Unable to upload images for the report when calling ipr_report. #36

Open faruqsandi opened 1 month ago

faruqsandi commented 1 month ago

Describe the bug Unable to upload images for the report when calling ipr_report.

To Reproduce Steps to reproduce the behavior:

  1. Run command  ipr_report
  2. with input:
    {
        "patientId": "Faruq-Test-Build-Report",
        "kbDiseaseMatch": "colorectal cancer",
        "project": "TEST",
        "template": "genomic",
        "ageOfConsent": 35,
        "alternateIdentifier": "fhir-patiet-id-here",
        "biopsyDate": "2021-06-04T16:36:37.279Z",
        "biopsyName": "colon",
        "ploidy": "diploid",
        "presentationDate": "2021-06-04T16:36:37.279Z",
        "subtyping": "adenocarcinoma",
        "images": [
            {
                "key": "mutationBurden.density_snv.primary",
                "path": "/absolute/path/to/pori_suite/mutationBurden.density_snv.primary.png",
                "title": "Mock Data",
                "caption": "Mock Data"
            }
    }
  3. See error (unnecessary details omitted):
    {'error': {'message': 'Error processing report image mutationBurden.density_snv.primary.png Error: Input file is missing: /home/bit/Playground/xnalabs/pori_suite/mutationBurden.density_snv.primary.png'}}

Expected behaviour I expected that the image would be successfully uploaded. I see that function post_images never actually called besides in test cases.

Versions (please complete the following information):  - OS: Windows 11, WSL 2, Ubuntu 22.04.4 LTS.  - Python: 3.11.9  - Version: pori_python==0.1.2  - GraphKB URL: local  - IPR URL: local

Additional context I tried to construct a complete JSON for ipr_report that will produce a complete report in each section.

dustinbleile commented 1 month ago

Input file is missing: /home/bit/Playground/xnalabs/pori_suite/mutationBurden.density_snv.primary.png The error is showing this file as missing or inaccessible.

Are read permissions restricted on that file? Is the directory correct.

faruqsandi commented 1 month ago

Yes, paths are guaranteed to be OK and accessible using terminal.

My current workaround is to remove the "images" from the payload for individual upload after report created.

images = report_payload.pop()

ipr_conn = IprConnection(
    username=username, password=password, url=myurl
)

for image in images:
    image_key = image["key"]
    files = {
        f"{image_key}": image["path"],
    }
    data = {
        f"{image_key}.title": image["title"],
        f"{image_key}.caption": image["caption"],
    }
    try:
        response_image = ipr_conn.post_images(
            report_id=report_id, files=files, data=data
        )
        print(image_key, response_image)
    except Exception:
        print(f"Failed to upload image {image_key}")
        continue

Here is my json: example_report.json