-
Notifications
You must be signed in to change notification settings - Fork 174
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
[API] Add dicom upload #9154
base: main
Are you sure you want to change the base?
[API] Add dicom upload #9154
Conversation
I must say I am not sure what I am supposed to do regarding the failed tests on files that I did not modify in the PR. Any direction @driusan (or someone else) 🤔. |
Line php/libraries/FilesDownloadHandler.php Line php/libraries/SiteIDGenerator.php |
Hum, yeah, I already saw that. I was just suprised to see that the errors are marked as originating from I'll tackle this tomorrow probably. |
I've looked at the static errors in more details, it appears to be mainly due to an upgrade of phpstan, which changes the typing of string conversions with However, I find the code that triggers the errors to be quite cryptic, with some lines that seem obviously wrong (at least according to typing). If someone who knows this code better than me could look into it, it would be best. In the meantime, I'm adding this to the next meeting. |
Probably because composer update was run, which triggered an update of the static checker. |
Ok it seems the linting errors are |
fd349f1
to
222b5d4
Compare
@ridz1208 Ok I finally finished updating and re-testing this PR. Generally it seems to work. However, if the pipeline fails during the latter stages, the DICOM archive previously inserted does not have its session initialized. This should be fixed with the new DICOM archive PR, but I don't expect it to be merged before at least a few weeks. |
4b8a6dc
to
9765668
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maximemulder I did a first pass of review. I did not have a chance to actually test the changes as my MCIN sandbox is not letting me logging in. Have to figure out why and it could take some time so figured I would do an initial review.
GET /candidates/$CandID/$VisitLabel/dicoms/$Tarname/processes | ||
``` | ||
|
||
The response contains all `mri_upload` attempts with the specified `$tarname`. And for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically, there should only be one UploadID
per TarchiveID
. So when you overwrite, you should grep the UploadID
associated to what is being overwritten instead of inserting a new entry in mri_upload
. Especially since the incoming directory content will be overwritten anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that there is only one MRI upload per DICOM archive, but I've seen a few cases in testing (even without this PR) where there are a few failed MRI uploads and one successful for a single file. This is how the batch uploader does it (don't know about other pipelines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. I think in principle, there should only be one upload per tarchive but unfortunately the batch upload script is not compliant with this set up. However, for the API, I think we should make sure this is the behaviour at minimum, to avoid duplicated entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this thread resolved?
Please remove all the unrelated changes (whitespace, variable name changes, etc). If necessary you can send those in another PR. It is not feasible to review this PR with so many unrelated changed mixed together. |
65869da
to
4c63612
Compare
I replied to all the comments and applied the suggested changes. I reverted the breaking changes to the API including floats / strings and naming. Back when I wrote them, I thought it was part of the original PR and not something that was already in LORIS. I made the terminology more consistent by using I also disabled my trailing spaces auto-removal and removed the associated changes. |
"SeriesDescription" : "MPRAGE_ipat2", | ||
"SeriesNumber" : "2", | ||
"SeriesNumber" : 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding this change, the current documentation is inaccurate, I can extract this to a separate PR if wanted.
Example:
https://demo.loris.ca/api/v0.0.4-dev/candidates/587630/V1/dicoms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to look into this to see if it's a bug in the documentation or the code. It seems weird that it's only the SeriesNumber that does it and it might be related to PHP (not LORIS) changes in the PDO over time.
It might be faster to split it out.
6f882bc
to
8112fc8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maximemulder I re-reviewed quickly your PR. A few additional comments:
- In the description of the PR, could you add a "Notes for existing project" with the information of the SQL patches to run?
07a0ec2
to
acd5bc8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
various comments
modules/api/docs/LorisRESTAPI.md
Outdated
The JSON can optionally have a boolean `Overwrite` attribute that can be used | ||
to overwrite an existing file (`false` if not present). | ||
A successful request will be answered by a `303 See Other` response with its | ||
`Location` header pointing to the processes list of the new upload. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be pointing to the new upload?
If an API user wanted the process list instead of the file itself after uploading a file, they could just append "/processes".
modules/api/docs/LorisRESTAPI.md
Outdated
|
||
Only `GET` is currently supported. | ||
To get a list of the processes and their status for a given DICOM study previously uploaded use the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a different endpoint, seems to be missing a subheader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added subheaders. Please tell me if there is anything wrong.
EDIT: Well, I'll remove those I added to existing 0.0.3 endpoints then.
EDIT 2: Whoopsie, there are a few mistakes in the commit. I'll correct it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subheaders v2:
"SeriesDescription" : "MPRAGE_ipat2", | ||
"SeriesNumber" : "2", | ||
"SeriesNumber" : 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to look into this to see if it's a bug in the documentation or the code. It seems weird that it's only the SeriesNumber that does it and it might be related to PHP (not LORIS) changes in the PDO over time.
It might be faster to split it out.
@@ -823,90 +823,192 @@ The JSON object is of the form: | |||
|
|||
## 5.0 DICOM Data | |||
|
|||
Like the imaging data, the DICOM data mostly lives in the `/candidates/$CandID/$Visit` | |||
portion of the REST API namespace, but is defined in a separate section of this | |||
Like the imaging data, the DICOM data mostly lives in the `/candidates/$CandID/$VisitLabel` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized my above comments were made on the 0.0.3 documentation which shouldn't be changed because it's already released. Pretend I made them on the v0.0.4-dev..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it ok to change the 0.0.3 documentation if it only clarifies the current behavior without changing it ? I would think it is ok personally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, clarifying the documentation is fine, changing the behaviour (incl adding new things) should only go into the dev version. An API client that uses version $x of the API should be able to expect the same behaviour if they point to a different LORIS instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I am not sure of what you are asking me to do. Do you want the API DICOM upload endpoints to only be added to 0.0.4-dev ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. (And pretend that the comments I made on them in 0.0.3 before realizing I was looking at the wrong one were made on 0.0.4-dev)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to duplicate the comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to duplicate the comments, I am going through each of them one by one anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit removes the documentation from the API v0.0.3. In practice, the new endpoints were already v0.0.4-only, but there are a few v0.0.4 POST routes that are added to v0.0.3 endpoints, not sure what do do here (ignore or implement method specific supported versions ?).
@@ -52,25 +52,25 @@ class MriUploadServerProcess extends AbstractServerProcess | |||
private $_sourceLocation; | |||
|
|||
/** | |||
* Root of the MRI files directory. | |||
* The value of MRICodePath config setting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to this file don't seem to be related to the API and should be moved to a different PR so someone more familiar with the server_processes_manager can review them.
acd5bc8
to
6c7af79
Compare
5660cf8
to
34d600e
Compare
84b6398
to
8230e89
Compare
6f3651d
to
0488bb0
Compare
Brief summary of changes
This is a port of #6161, which contains a description of the changes. Since the old PR has diverged quite a bit from the main branch, and that its author no longer works here, I found it easier to copy the changes on the current main branch and open a new PR rather than to rebase the PR. While porting, I only rewrote the old PR code whenever static analysis or practical stests showed that it was no longer in sync with the main branch (or when my IDE removed trailing spaces).
Testing instructions (if applicable)
Notes for existing projects
This PR requires to run the following SQL patch
SQL/New_patches/2024-03_19-MRIUploadServerProcessRel.sql
.