diff options
| author | cjd24 | 2018-04-23 20:41:10 +0100 |
|---|---|---|
| committer | cjd24 | 2018-04-23 20:41:10 +0100 |
| commit | e2a3b8f528d4da7bb3e74a9a75541d1aa9f6654f (patch) | |
| tree | 8e60600b3bef919fd4a8df30404e73babe98ad86 | |
| parent | Include header row as first row in `tabular` view (diff) | |
| download | medicine-e2a3b8f528d4da7bb3e74a9a75541d1aa9f6654f.tar.gz medicine-e2a3b8f528d4da7bb3e74a9a75541d1aa9f6654f.zip | |
Final report push?
| -rw-r--r-- | ecosystem.config.js | 2 | ||||
| -rw-r--r-- | report/deliverable-3/texts/aims.tex | 2 | ||||
| -rw-r--r-- | report/deliverable-3/texts/code.tex | 16 | ||||
| -rw-r--r-- | report/deliverable-3/texts/contributions.tex | 14 | ||||
| -rw-r--r-- | report/deliverable-3/texts/conversion.tex | 44 | ||||
| -rw-r--r-- | report/deliverable-3/texts/testing.tex | 4 | ||||
| -rw-r--r-- | src/FileRouter.ts | 2 | ||||
| -rw-r--r-- | src/fileChunk.py | 37 |
8 files changed, 100 insertions, 21 deletions
diff --git a/ecosystem.config.js b/ecosystem.config.js index 060e79a..5fe5685 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -9,7 +9,7 @@ module.exports = { script: 'src/index.ts', // cwd: '.', args: '', - instances: 1, + instances: 4, watch: false, ignore_watch: '', max_memory_restart: '1G', diff --git a/report/deliverable-3/texts/aims.tex b/report/deliverable-3/texts/aims.tex index 3543313..c64ca0c 100644 --- a/report/deliverable-3/texts/aims.tex +++ b/report/deliverable-3/texts/aims.tex @@ -2,6 +2,6 @@ As we already had most of the basic implementation working since our second submission, our main task for the final deadline was resolving numerous issues, extending the test coverage and completing file conversion. Several meetings were organised between groups to check the compatibility between our back-end system and HCI and machine-learning groups. \begin{description} \item[Extend Test Coverage] Verification and validation of our server's functionality became the focus of our last submission. - \item[File Upload, Download and Conversion] One of the last remaining tasks for this submission was implementing the serving of files through our server. + \item[File Upload, Download and Conversion] One of the last remaining tasks for this submission was implementing the serving of files through our server, including the interactivity of zoomable images. \item[Intra-group Collaboration] The key to ensuring the success of our system was testing the compatibility of our server with the work of other groups. \end{description} diff --git a/report/deliverable-3/texts/code.tex b/report/deliverable-3/texts/code.tex index 6fe316b..d58bf7b 100644 --- a/report/deliverable-3/texts/code.tex +++ b/report/deliverable-3/texts/code.tex @@ -3,4 +3,18 @@ To ensure code clarity and quality, we decided to use the linter `ts-lint'. This did not only help us create professional-style code but also aided in avoiding bugs early by catching out common errors. The linter was integrated with our editors as well as yarn as to automate its work-flow. \subsection{Scripts} -Several scripts were created to automate the installation and execution process.
\ No newline at end of file +Several scripts were created to automate the installation and execution process. + +\subsection{Caching} +As we carried out testing of the serving of tileable images, we were finding that there was a significant amount of wasted computation taking place +which was slowing down requests significantly. This was as a result of computing/stitiching and cutting regions of images even as a result of a +repeated request from the frontend even if we had just done and written this to a file. + +In order to combat this we added a further database to our backend design called Redis. This database is optimised for caching. +We decided that the best item to cache would be a specific URL request since this contained all the parameters used to figure +out the region of the image to get. The value of the URL key, would be the filepath of the image which matches this URL's parameters on disk. +Therefore if a duplicate request comes in, we can skip all image computation and simply stream the results of the image back to the client instantly. + +We planned to push this caching even higher still, and cache every request made to the server. This would be especially beneficial to things requiring access +into supported views etc since file reads can be skipped and any navigation of the other database/filesystem or raw file computation/generation could be skipped. +Regrettably we did not have the time to get this far, so currently only image tile requests are cached. diff --git a/report/deliverable-3/texts/contributions.tex b/report/deliverable-3/texts/contributions.tex index 62f3892..ce60516 100644 --- a/report/deliverable-3/texts/contributions.tex +++ b/report/deliverable-3/texts/contributions.tex @@ -1,15 +1,21 @@ \section{Individual Contributions} \subsection{Tom Harley} \subsection{Josh Lee} -My main involvement thought-out this year has been my work on the database. This involved the setup, implementation and maintenance to add required features and to continuously integrate with the others in the group to provide a robust working system that satisfied all of the specification. I used Postgres and Sequelize as the foundation for the database as these were both reliable and extensive platforms with a-lot of additional support that helped me work with other members of my group. A big part of the database was implementing user and project based permissions that encompassed how users could interact with the database, I also worked with Hafeez in combining the permissions and the passport authorisation to guarantee the security of the server. The database also provided a file system that aided in storing and retrieving files and managing projects and folders. +My main involvement thought-out this year has been my work on the database. This involved the setup, implementation and maintenance to add required features and to continuously integrate with the others in the group to provide a robust working system that satisfied all of the specification. I used Postgres and Sequelize as the foundation for the database as these were both reliable and extensive platforms with a-lot of additional support that helped me work with other members of my group. A big part of the database was implementing user and project based permissions that encompassed how users could interact with the database, I also worked with Hafeez in combining the permissions and the passport authorisation to guarantee the security of the server. The database also provided a file system that aided in storing and retrieving files and managing projects and folders. Once the database was fully functional it was a case of implementing the file router to the specific defined protocol. This involved matching the request and response types for each request, error handling in the correct format and making sure that the expected functionality was being carried out each time. We used unit testing as much as possible throughout the process to implement this. My view on the project was that as a group we built an exceptional system that met all the basic functionality, also I felt we went beyond the scope, adding additional features where we felt necessary. We worked well with each other throughout the year adapting our meeting and sprint times to fit round each others work and deadlines to consistently work on the project right up until the final hand in. \subsection{Calum Duff} +My most significant contribution to this project was the support of `Zeiss' files as a scalable image. I wrote all of the `C' code to interpret the binary file format data as described by the documention for the propriator file format. I then wrote all of the code to handle the extractor files, and grid them up onto a standard to be easily indexable. I also create an object used to efficiently map a request suited to the filetype to the actual image tile of interest. + +I also wrote the code to parse and convert spreadsheet style content and serve as csv etc. There is also support for `Lecia' files in terms of image input and file creation, however there was not a chance to plumb this in to the endpoints. +In the beginning, I worked extensively with Yom to implement the database orm and initial endpoints. After the main bulk of the work for CZI pyramids was complete I then also worked extensively with Tom again to bug fix endpoints, connect my conversion modules to the main serving capabilities of the backend, and ensure basic comprehension of HCI/ML linking with our endpoints. + +Overall I feel that there is a vast depth of work been completed in terms of the file conversion and specifically with CZI support, which achieves near perfect results and huge performance gains. \subsection{Johannes Weck} Throughout the development of our back-end server, I was responsible for thorough testing, which involved writing unit tests with mocha and chai, running integration tests through Postman as well as identifying and fixing bugs. One of the main challenges in this respect was understanding code written by other team-members. Clear and frequent communication between all members proved essential to this process. -During the last sprint I worked closely with Hafeez using pair-programming to resolve a range of issues flagged by the tests. Furthermore, I worked with Tom and Callum, finalizing server-side file-management. I was mostly involved with the file-system part of file storage, integrating the node-module `multer' with our server. `multer' was later swapped out for the package `body-parser' to allow compatibility with our assigned ML and HCI groups. +During the last sprint I worked closely with Hafeez using pair-programming to resolve a range of issues flagged by the tests. Furthermore, I worked with Tom and Calum, finalizing server-side file-management. I was mostly involved with the file-system part of file storage, integrating the node-module `multer' with our server. `multer' was later swapped out for the package `body-parser' to allow compatibility with our assigned ML and HCI groups. \subsection{Hafeez Abdul-Rehaman} -My role in the development of the server, involved producing the authentication system and providing security to each of the routes in the RESTful API. This was done through node.js libraries including \textit{passportjs} and \textit{jsonwebtokens}. I also tested the functionality of this after implementation to ensure it was working using tools such as Postman and curl. Whilst also conducting tests for authentication, I assisted Johannes in running and resolving test issues found in other parts of the implementation. By using more than one team member on larger tasks, it took less time to solve these problems. This took a considerable amount of time during the last sprint, as testing was required to be much larger and thorough for the fully implemented system. During the later sprints, I was also designated as scrum master. This meant I was responsible for organising tasks and managing time, and removing obstacles the team may face. +My role in the development of the server, involved producing the authentication system and providing security to each of the routes in the RESTful API. This was done through node.js libraries including \textit{passportjs} and \textit{jsonwebtokens}. I also tested the functionality of this after implementation to ensure it was working using tools such as Postman and curl. Whilst also conducting tests for authentication, I assisted Johannes in running and resolving test issues found in other parts of the implementation. By using more than one team member on larger tasks, it took less time to solve these problems. This took a considerable amount of time during the last sprint, as testing was required to be much larger and thorough for the fully implemented system. During the later sprints, I was also designated as scrum master. This meant I was responsible for organising tasks and managing time, and removing obstacles the team may face. -As a team member, I did not feel that there were any major obstacles which impeded the development of the system. However, there were some issues regarding time and managing work set out by other modules within the Computer Science course. Some sprints clashed with other pieces of coursework that also needed to be completed. Therefore, additional care was needed when organising tasks related to the project and planning was required for an extended period of time which would overlap other upcoming coursework deadlines. This way as a team we could plan around other unrelated submissions.
\ No newline at end of file +As a team member, I did not feel that there were any major obstacles which impeded the development of the system. However, there were some issues regarding time and managing work set out by other modules within the Computer Science course. Some sprints clashed with other pieces of coursework that also needed to be completed. Therefore, additional care was needed when organising tasks related to the project and planning was required for an extended period of time which would overlap other upcoming coursework deadlines. This way as a team we could plan around other unrelated submissions. diff --git a/report/deliverable-3/texts/conversion.tex b/report/deliverable-3/texts/conversion.tex index 87db332..dff931f 100644 --- a/report/deliverable-3/texts/conversion.tex +++ b/report/deliverable-3/texts/conversion.tex @@ -112,18 +112,19 @@ up to the next power of two (2048) and collecting 4 images together then scaling This process can be repeated for each level of zoom we would like to raise to. This will massively speed up the process of searching through base tiles and stitching many together if we pre-process all of the intermediate layers. Since most HCI groups are using OpenSeaDragon (which requests things in scales of powers -of two~\cite{openseadragon}), our approach should be a very fast performer with the trade off of larger up-front processing time.\\ -Indexing into this pyramid will be fast with each request too, as they will be separated by `C' value, which is -one of the image's layering options, then by zoom level. +of two~\cite{openseadragon}), our approach should be a very fast performer with the trade off of larger up-front pre-processing time.\\ +Indexing into this pyramid will be extremely fast with each request too, as they will be separated by `C' value, which is +one of the image's layering options, then by zoom level, then you are straight into the 2d plane. \subsection{Leica \& Other Formats} -As Zeiss is such a difficult and mammoth file format almost all of my time was spent dealing with purely this, -and it is still not even complete yet. However having looked quickly into Leica, there appears to be -library support, which may make life easier, along with the fact the internal structure appears to be similar to -a BigTiff. More progress on this format will take place for the next deliverable. +As Zeiss is such a difficult and mammoth file format almost all of my time was spent dealing with purely this. +However having looked quickly into Leica, there appears to be +With Leica files, once more research was done into their format, it was found that they are actually identical +to BigTiffs, with the only difference being a meta value which is optional in tif is mandatory in Lecia. -As for other image formats such as JPEG, TIFF etc. These are standard formats and so will be trivial to -convert to our required standard of PNG so is not a significant point of progress currently. +With this discovered, and with our chosen image processing library `sharp' on hand, which can natively convert Tiff to +`.dzi' which is the standard that OpenSeaDragon seems to prefer, then if a file was a Lecia it became as trivial to convert +as other image formats such as JPEG etc. \subsection{Non image formats (\file{.csv} etc.)} As for non image formats such as \file{.csv}, it has been decided that the backend should only be responsible of hosting these @@ -131,5 +132,26 @@ files, since there is no way that a backend server could possibly predict what t Additionally, there are also many cases where an end-user may wish to deliberately store something in a format which a backend server checking legitimacy of the file would complain about incorrectly. -The team hasn't really looked into things such as Excel (\file{.xlsx}) files, however again, pre-emptively looking, there seems to -be fairly wide library support for things like this, so it was not a major concern for this deliverable. +Another of the client desired file formats support was Excel (\file{.xlsx}). This was fairly easy to complete too. +We loaded a library that was capable of parsing the binary and transforming it into an object which is easier to work with. +This object can then be converted to csv for each sheet in the workbook and various files written and recorded to describe +how this is lain out. + +\subsection{Final Results of conversion} +With the end of Deliverable 3, we carried out some integration testing. +Unfortunately we came across a significant number of problems with regards the running of the conversion code through no fault of our own. + +For example, the max filesize of postman was exceded with even the smallest of CZI files. The host servers have some process creation limitations +and therefore do not allow the conversion side of the code to be run on them, as such any and all conversion needed to take place on the +scratch drive of a local lab machine, which is significantly less powerful, and so all testing took substantial time. + +Since we were not able to upload the file directly there needed to be some live editing of our postgres database at run time to full the system +into beleiving that it had a file uploaded as a CZI. Much to our delight however, we did get a sample of this working, and found a sucessful +integration with an HCI group, whereby they were able to load the CZI endpoint and zoom and pan the image by requesting tiles precreated by the backend! + +The actual computation required to crunch down a CZI file into something that can be easily read and used by the end user is \emph{massive}. Huge amounts +of testing and raw image computation/buffer manipulation is carried out in order to normalise regions and arrange them in a sensible format. +From what we can tell of other backend groups, noone else even attempted to get image support for these formats, yet I have achieved full support. +(albeit in some confined rules of the system environment required to allow the code to actually run). + +We are very proud of this level of support, and only wish we had a longer time to test and optimise it further in serving it. diff --git a/report/deliverable-3/texts/testing.tex b/report/deliverable-3/texts/testing.tex index 7842f9f..db76713 100644 --- a/report/deliverable-3/texts/testing.tex +++ b/report/deliverable-3/texts/testing.tex @@ -2,9 +2,9 @@ Testing was a key process in the development of the final product just as it was in previous submission. Testing was particular important to determine whether the final system meets the requirements initially set. As well as testing each module individually, further tests were done upon completing the system through integration with the front-end and machine learning systems. \subsection{Using Mocha and Postman} -The JavaScript framework Mocha was still used in the testing process for modules. The test-suite for our project had some major work done since the last submission, allowing tests to run on the Gitlab server as well as addressing bugs in the test-suite and implementation. Whilst also using Mocha for Unit tests, it was used to test the individual routes and their response whilst comparing them to a template. The same method was applied to test requests. This automation increased the efficiency of production, however, the small amount of routes to test allowed us to be more thorough by manually sending requests to the server using Postman. Postman is a API development tool which allows requests to be sent through an easily manageable user interface. By doing this, expected values were easy to match with actual values, and further bugs could be caught even when the templates had matched previously. +The JavaScript framework Mocha was still used in the testing process for modules. The test-suite for our project had some major work done since the last submission, allowing tests to run on the Gitlab server as well as addressing bugs in the test-suite and implementation. Whilst also using Mocha for Unit tests, it was used to test the individual routes and their response whilst comparing them to a template. The same method was applied to test requests. This automation increased the efficiency of production, however, the small amount of routes to test allowed us to be more thorough by manually sending requests to the server using Postman. Postman is a API development tool which allows requests to be sent through an easily manageable user interface. By doing this, expected values were easy to match with actual values, and further bugs could be caught even when the templates had matched previously. >>>>>>> report \subsection{Integration Testing} -Once the system had been fully implemented and tested, it was necessary to integrate with the rest of the system such as user interface and the machine learning servers. This allowed us to determine whether specific protocols were implemented correctly and to ensure that all the requirements set by the client were met. To begin the integration process, the server was hosted through the St Andrews web service which allows content to be hosted through the web. This was done by configuring an \textit{nginx} proxy that would allow binding of the loopback address and port number. Using \texttt{tmux}, the session was hosted persistently as it allows terminal sessions to be detached and run in the background. The server runs on the domain \textit{har4.host.cs.st-andrews.ac.uk}. From here, it was possible for other teams to send requests to the running server. +Once the system had been fully implemented and tested, it was necessary to integrate with the rest of the system such as user interface and the machine learning servers. This allowed us to determine whether specific protocols were implemented correctly and to ensure that all the requirements set by the client were met. To begin the integration process, the server was hosted through the St Andrews web service which allows content to be hosted through the web. This was done by configuring an \textit{nginx} proxy that would allow binding of the loopback address and port number. Using \texttt{tmux}, the session was hosted persistently as it allows terminal sessions to be detached and run in the background. The server runs on the domain \textit{har4.host.cs.st-andrews.ac.uk}. From here, it was possible for other teams to send requests to the running server. \subsubsection{CORS} Integration testing also gave the opportunity to find additional errors specifically caused by the linking of servers. An example of this is the realisation of the lack of Cross-Origin support. The running server could not function properly as content requests were being sent to different origins and for security reasons this is not permitted. To fix this additional features were required to be implemented to support CORS. Specifically certain headers were added to permit different origin access. diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 94ffa63..dbd556f 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -1023,7 +1023,7 @@ export class FileRouter { this.router.get ('/projects/:project_name/files/*', getFilePath); this.router.post( '/projects/:project_name/files/*', - bodyParser.raw({ type: '*/*', limit: '20GB' }), postFilePath); + bodyParser.raw({ type: '*/*', limit: '1GB' }), postFilePath); this.router.get ('/projects/:project_name/files_by_id/:id', getFileId); } diff --git a/src/fileChunk.py b/src/fileChunk.py new file mode 100644 index 0000000..b8a00c5 --- /dev/null +++ b/src/fileChunk.py @@ -0,0 +1,37 @@ +import requests + +token = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvYmplY3QiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwYXNzd29yZEludGVybmFsIjpudWxsLCJjcmVhdGlvbkRhdGUiOiIyMDE4LTA0LTIzVDA2OjA1OjQwLjYwNloiLCJ1cGRhdGVkQXQiOiIyMDE4LTA0LTIzVDA2OjA1OjQwLjYwNloiLCJ1c2VyR3JvdXBzIjpbeyJpZCI6MSwibmFtZSI6ImxvZ2dpbmciLCJjYW5DcmVhdGVVc2VycyI6bnVsbCwiY2FuRGVsZXRlVXNlcnMiOm51bGwsImNhbkVkaXRVc2VycyI6bnVsbCwiY2FuQ3JlYXRlUHJvamVjdHMiOm51bGwsImNhbkRlbGV0ZVByb2plY3RzIjpudWxsLCJjYW5FZGl0UHJvamVjdHMiOm51bGwsImNhbkFjY2Vzc0xvZ3MiOnRydWUsImlzSW50ZXJuYWwiOmZhbHNlLCJkZXNjcmlwdGlvbiI6IkFsbG93cyBQb3N0IHRvIExvZyIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6MX19LHsiaWQiOjIsIm5hbWUiOiJhZG1pbiIsImNhbkNyZWF0ZVVzZXJzIjp0cnVlLCJjYW5EZWxldGVVc2VycyI6dHJ1ZSwiY2FuRWRpdFVzZXJzIjp0cnVlLCJjYW5DcmVhdGVQcm9qZWN0cyI6dHJ1ZSwiY2FuRGVsZXRlUHJvamVjdHMiOnRydWUsImNhbkVkaXRQcm9qZWN0cyI6dHJ1ZSwiY2FuQWNjZXNzTG9ncyI6bnVsbCwiaXNJbnRlcm5hbCI6ZmFsc2UsImRlc2NyaXB0aW9uIjoiU3lzdGVtcyBhZG1pbiIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6Mn19XSwicHJvamVjdHMiOltdfSwiaWF0IjoxNTI0NDYzNTY3LCJleHAiOjE1MjQ0ODUxNjd9.uJIsxoUyqECt_4rJFpipcT12E0dmWsQi_381usVg0zY" +chunksize = 1024 * 1024 * 4; + + +def read_in_chunks(file_object): + """Lazy function (generator) to read a file piece by piece. + Default chunk size: 1k.""" + while True: + data = file_object.read(chunksize) + if not data: + break + yield data + + +f = open('/cs/scratch/cjd24/0701.czi') +if __name__ == "__main__": + iterator = read_in_chunks(f) + + r = requests.post("http://localhost:3000/cs3099group-be-4/projects/fake-project/files/0701.czi", headers={"authorization":token}, data=iterator.next()) + + print(r.text) + + offset = chunksize; + current = iterator.next() + while(True): + nchunk = iterator.next() + if not nchunk: + r = requests.post("http://localhost:3000/cs3099group-be-4/projects/fake-project/files/0701.czi?overwrite=true&offset=" + str(offset) + "&final=true", headers={"authorization":token}, data=current) + print(r.text) + break; + + r = requests.post("http://localhost:3000/cs3099group-be-4/projects/fake-project/files/0701.czi?overwrite=true&offset=" + str(offset), headers={"authorization":token}, data=current) + print(r.text) + current = nchunk; + offset += chunksize |
