<commit_before>panex-web-api
=============

Panex Web API


###Routes
---------

``` bash

                         POST   /patients/:patient_id/patient_data/upload(.:format) patient_data#upload
                         GET    /patients/:patient_id/patient_data(.:format)        patient_data#index
   patients_patient_data GET    /patients/patient_data(.:format)                    patient_data#index_all
                patients GET    /patients(.:format)                                 patients#index
                         POST   /patients(.:format)                                 patients#create
             new_patient GET    /patients/new(.:format)                             patients#new
            edit_patient GET    /patients/:id/edit(.:format)                        patients#edit
                 patient GET    /patients/:id(.:format)                             patients#show
                         PUT    /patients/:id(.:format)                             patients#update
                         DELETE /patients/:id(.:format)                             patients#destroy
                    apps GET    /apps(.:format)                                     apps#index
                     app GET    /apps/:id(.:format)                                 apps#show
                services GET    /services(.:format)                                 services#index
                 service GET    /services/:id(.:format)                             services#show
        new_user_session GET    /users/sign_in(.:format)                            sessions#new
            user_session POST   /users/sign_in(.:format)                            sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)                           sessions#destroy
           user_password POST   /users/password(.:format)                           devise/passwords#create
       new_user_password GET    /users/password/new(.:format)                       devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)                      devise/passwords#edit
                         PUT    /users/password(.:format)                           devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)                             devise/registrations#cancel
       user_registration POST   /users(.:format)                                    devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)                            devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)                               devise/registrations#edit
                         PUT    /users(.:format)                                    devise/registrations#update
                         DELETE /users(.:format)                                    devise/registrations#destroy
               user_apps GET    /users/:user_id/apps(.:format)                      apps#index
                         POST   /users/:user_id/apps(.:format)                      apps#create
            new_user_app GET    /users/:user_id/apps/new(.:format)                  apps#new
           edit_user_app GET    /users/:user_id/apps/:id/edit(.:format)             apps#edit
                user_app GET    /users/:user_id/apps/:id(.:format)                  apps#show
                         PUT    /users/:user_id/apps/:id(.:format)                  apps#update
                         DELETE /users/:user_id/apps/:id(.:format)                  apps#destroy
           user_services GET    /users/:user_id/services(.:format)                  services#index
                         POST   /users/:user_id/services(.:format)                  services#create
        new_user_service GET    /users/:user_id/services/new(.:format)              services#new
       edit_user_service GET    /users/:user_id/services/:id/edit(.:format)         services#edit
            user_service GET    /users/:user_id/services/:id(.:format)              services#show
                         PUT    /users/:user_id/services/:id(.:format)              services#update
                         DELETE /users/:user_id/services/:id(.:format)              services#destroy
                   users GET    /users(.:format)                                    users#index
                         POST   /users(.:format)                                    users#create
                new_user GET    /users/new(.:format)                                users#new
               edit_user GET    /users/:id/edit(.:format)                           users#edit
                    user GET    /users/:id(.:format)                                users#show
                         PUT    /users/:id(.:format)                                users#update
                         DELETE /users/:id(.:format)                                users#destroy
                    root        /                                                   home#index



```

###Requirements
---------------
Symlink your system folder with rails public/system folder
``` perl
bash $ ln -s /panex/system public/system 
```

###Job Management
-----------------

####Delayed Job

Uses [Delayed Job][1] for management of worker tasks.

In order to make the the realtime viewing of the tasks online, there is a web interface to it [Delayed Job Web][2].

Must run following in testing mode:
```
rake jobs:work
```

In production must use the following:
``` bash
RAILS_ENV=production script/delayed_job start
RAILS_ENV=production script/delayed_job stop

# Runs two workers in separate processes.
RAILS_ENV=production script/delayed_job -n 2 start
RAILS_ENV=production script/delayed_job stop

# Set the --queue or --queues option to work from a particular queue.
RAILS_ENV=production script/delayed_job --queue=tracking start
RAILS_ENV=production script/delayed_job --queues=mailers,tasks start

# Runs all available jobs and the exits
RAILS_ENV=production script/delayed_job start --exit-on-complete
# or to run in the foreground
RAILS_ENV=production script/delayed_job run --exit-on-complete
```

[1]: https://github.com/collectiveidea/delayed_job
[2]: https://github.com/ejschmitt/delayed_job_web<commit_msg>Add Instructions for Service creation<commit_after>panex-web-api
=============

Panex Web API


###Routes
---------

``` bash

                         POST   /patients/:patient_id/patient_data/upload(.:format) patient_data#upload
                         GET    /patients/:patient_id/patient_data(.:format)        patient_data#index
   patients_patient_data GET    /patients/patient_data(.:format)                    patient_data#index_all
                patients GET    /patients(.:format)                                 patients#index
                         POST   /patients(.:format)                                 patients#create
             new_patient GET    /patients/new(.:format)                             patients#new
            edit_patient GET    /patients/:id/edit(.:format)                        patients#edit
                 patient GET    /patients/:id(.:format)                             patients#show
                         PUT    /patients/:id(.:format)                             patients#update
                         DELETE /patients/:id(.:format)                             patients#destroy
                    apps GET    /apps(.:format)                                     apps#index
                     app GET    /apps/:id(.:format)                                 apps#show
                services GET    /services(.:format)                                 services#index
                 service GET    /services/:id(.:format)                             services#show
        new_user_session GET    /users/sign_in(.:format)                            sessions#new
            user_session POST   /users/sign_in(.:format)                            sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)                           sessions#destroy
           user_password POST   /users/password(.:format)                           devise/passwords#create
       new_user_password GET    /users/password/new(.:format)                       devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)                      devise/passwords#edit
                         PUT    /users/password(.:format)                           devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)                             devise/registrations#cancel
       user_registration POST   /users(.:format)                                    devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)                            devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)                               devise/registrations#edit
                         PUT    /users(.:format)                                    devise/registrations#update
                         DELETE /users(.:format)                                    devise/registrations#destroy
               user_apps GET    /users/:user_id/apps(.:format)                      apps#index
                         POST   /users/:user_id/apps(.:format)                      apps#create
            new_user_app GET    /users/:user_id/apps/new(.:format)                  apps#new
           edit_user_app GET    /users/:user_id/apps/:id/edit(.:format)             apps#edit
                user_app GET    /users/:user_id/apps/:id(.:format)                  apps#show
                         PUT    /users/:user_id/apps/:id(.:format)                  apps#update
                         DELETE /users/:user_id/apps/:id(.:format)                  apps#destroy
           user_services GET    /users/:user_id/services(.:format)                  services#index
                         POST   /users/:user_id/services(.:format)                  services#create
        new_user_service GET    /users/:user_id/services/new(.:format)              services#new
       edit_user_service GET    /users/:user_id/services/:id/edit(.:format)         services#edit
            user_service GET    /users/:user_id/services/:id(.:format)              services#show
                         PUT    /users/:user_id/services/:id(.:format)              services#update
                         DELETE /users/:user_id/services/:id(.:format)              services#destroy
                   users GET    /users(.:format)                                    users#index
                         POST   /users(.:format)                                    users#create
                new_user GET    /users/new(.:format)                                users#new
               edit_user GET    /users/:id/edit(.:format)                           users#edit
                    user GET    /users/:id(.:format)                                users#show
                         PUT    /users/:id(.:format)                                users#update
                         DELETE /users/:id(.:format)                                users#destroy
                    root        /                                                   home#index



```

###Requirements
---------------
Symlink your system folder with rails public/system folder
``` perl
bash $ ln -s /panex/system public/system 
```

###Job Management
-----------------

####Delayed Job

Uses [Delayed Job][1] for management of worker tasks.

In order to make the the realtime viewing of the tasks online, there is a web interface to it [Delayed Job Web][2].

Must run following in testing mode:
```
rake jobs:work
```

In production must use the following:
``` bash
RAILS_ENV=production script/delayed_job start
RAILS_ENV=production script/delayed_job stop

# Runs two workers in separate processes.
RAILS_ENV=production script/delayed_job -n 2 start
RAILS_ENV=production script/delayed_job stop

# Set the --queue or --queues option to work from a particular queue.
RAILS_ENV=production script/delayed_job --queue=tracking start
RAILS_ENV=production script/delayed_job --queues=mailers,tasks start

# Runs all available jobs and the exits
RAILS_ENV=production script/delayed_job start --exit-on-complete
# or to run in the foreground
RAILS_ENV=production script/delayed_job run --exit-on-complete
```

###Service Management
---------------------
For developers who are interested in developing backend services for the online system, you must make sure of the following things:
  * Submit your services as packaged zip files, don't submit individual libraries etc.
  * Make sure your packaged out-of-the-box service runs as scheduled, otherwise you as a developer will be sent emails about the service failing to run. Keep to the server's configuration
  * If there are scripts that you wish to run you can do in a file called `.setup` supplied in your zipped collection. It is a `bash` script and does your initial setup job
  * Your program binary will be invoked as specfied in `commandLine` field during upload. e.g. a valid command line can be `java myprogram`, this ofcourse assumes you run a `javac myprogram.java` in your `.setup` file. 
  * In addition you will be provided 2 more parameters `input_dir` and `output_dir` in the command line, you must use these as the location of input and output files respectively. This is done as there might be some services which will work on only some files or perhaps on all the files and produce multiple/single results. All these will be linked back to the patient and browsed as such.
  * As such you must make sure to run through all the files within the directory yourself. The service is run in a sandbox so you will not have access to other directories other than the current one (in which your program will be placed)


[1]: https://github.com/collectiveidea/delayed_job
[2]: https://github.com/ejschmitt/delayed_job_web
{'fraction_non_alphanumeric': 0.08857408599842599, 'fraction_numerical': 0.0007870072261572583, 'mean_word_length': 1.4095845543871746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1101220', 'n_tokens_mistral': 3452, 'n_tokens_neox': 3334, 'n_words': 870}