https://github.com/alan-turing-institute/simulate-middleware
Simulate middleware service.
https://github.com/alan-turing-institute/simulate-middleware
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
5 of 6 committers (83.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.6%) to scientific vocabulary
Repository
Simulate middleware service.
Basic Info
- Host: GitHub
- Owner: alan-turing-institute
- Language: Python
- Default Branch: master
- Homepage: http://simulate.readthedocs.io
- Size: 314 KB
Statistics
- Stars: 0
- Watchers: 19
- Forks: 0
- Open Issues: 9
- Releases: 0
Metadata Files
readme.md
Simulate Middleware
The simulate middleware stores the current status of all cases and jobs. It does minimal processing, and serves primarily as a persistent store of state (but not of data).
Configuration
In order to run the system you must setup the config.json file with the correct
urls for the database and job manager. An example configuration is:
json
{
"database_url": "postgres://sg:sg@postgres/sg",
"job_manager_url": "localhost:9000"
}
Note that the database_url is an SqlAlchemy database connection string.
Running The System
Ensure that you have installed Docker.
Start the Docker daemon if it is not already running.
If this is the first time you are running the system, run the Postgres server individually in order for it to set itself up.
shell docker-compose run postgresShutdown the Postgres server.
shell docker-compose downBring up the full system.
shell docker-compose upIf you need to add demo data to the system send a
POSTrequest tohttp://localhost:5000/test. This will returnnull.Connect to the running server at (http://localhost:5000).
To bring the system down (saving the database state)
shell docker-compose downIf you ever need to work with the database run (assuming you have already brought the system down):
shell docker-compose run -d postgres docker psThis will show aCONTAINER IDfor the container that you just created. Connect to this container with:shell docker exec -it <container id> /bin/bashOnce inside the shell you can connect to the database with:shell psql -U sg -W sgwith the passwordsgWhen you are finished. Quit from bothpsqland the shell and run:shell docker-compose downIf you have Postgres installed on your local machine, you can connect to the docker
Postgresinstance directly by running:shell docker-compose run -d -p "8082:5432" postgres psql -U sg -W -p 8082 -h localhost sgWhen you are finished run:shell docker-compose down
Helpful SQL Commands
Just as a reminder here are some helpful PostgreSQL commands that may be helpful:
List all tables:
sql \dtGet all cases. Note that because the
casetable name clashes with an SQL keyword, you must wrap the table name in"sql SELECT * FROM "Case";Delete all tables:
sql DROP TABLE IF EXISTS "case", job_parameter, job_parameter_template, job_parameter_template_value, script, Case_Field, ParameterSpec, Job, JobParameter, JobParameterTemplate, JobParameterTemplateValue CASCADE;
Using The Middleware
The Flask app creates a server at localhost:5000.
The following is a list of endpoints and their functionality.
/case
This endpoint is responsible for managing the list of cases.
GET
A GET on this end point allows for paginated listing of all the cases in the system.
Arguments
It supports the following query args:
page(optional, default=1) gives the page of output that you are requesting. The first page is 1. If you ask for a page that does not exist (i.e off the end) you will get an empty list.per_page(optional, default=10) gives the number of results per page to return.
No information about whether the next page exists is returned. This is because I am expecting this to be used as part of an infinite scrolling system, where there is no explicit display to the user to ask for more (or if there a button to support error situations, returning no extra data is a valid response).
Return
Returns a list of case metadata for the selected cases. (May be empty). The format is:
json
[
{
"name": "Case name",
"id": "Case id",
"links": {
"self": "Link to more details about this case"
}
},
...
]
/cases/<id>
This endpoint is responsible for managing the details of a specific case.
GET
Gets the full details for a single case. This retrieves the entire case and serialises it for the user.
Arguments
No arguments are accepted.
Return
Returns the full details of a specific case with the following structure:
json
{
"name": "Case Name",
"id": "Case Id",
"fields": [
{
"name": "Case Field Name",
"specs": [],
"child_fields": [
{
"name": "Case Field Name",
"specs": [
{
"name": "Parameter name",
"value": "Parameter Value",
"id": "Parameter id"
},
...
],
"child_fields": []
},
...
]
}
]
}
/job/
This endpoint manages the list of all jobs.
GET
Paginate through a list of all existing jobs.
Arguments
It supports the following query args:
page(optional, default=1) gives the page of output that you are requesting. The first page is 1. If you ask for a page that does not exist (i.e off the end) you will get an empty list.per_page(optional, default=10) gives the number of results per page to return.
No information about whether the next page exists is returned. This is because I am expecting this to be used as part of an infinite scrolling system, where there is no explicit display to the user to ask for more (or if there a button to support error situations, returning no extra data is a valid response).
Return
Returns a list of jobs with the following format:
json
[
{
"name": "Job name",
"user": "Job creation user",
"id": "Job id",
"links": {
"self": "Link to full job details",
"case": "Link to full details of generating case"
},
},
...
]
POST
Create a new job
Arguments
Takes the following JSON structure in the body:
json
{
"user": "Creating user",
"name": "Job name",
"case_id": "Parent case"
}
Return
If not enough fields are provided the following structure will be returned:
json
{
"messages": {
"author": [ "Missing data for required field." ],
"name": [ "Missing data for required field." ],
"case_id": [ "Missing data for required field." ]
}
}
If the job name and details are not accepted (i.e. the pair of job name and author already exists) the following will be returned:
json
{
"message": "Sorry, these parameters have already been used. You have requested this URI [/job] but did you mean /job or /job/ ?"
}
If the job is successfully created, the following will be returned:
json
{
"job_id": new_job_id
}
/job/<id>
This endpoint is responsible for dealing with the details of a specific job.
GET
Get the details of the current job
Arguments
This end point accepts no arguments
Return
json
{
"user": "username",
"id": job_id,
"name": "Job_name",
"values": [
{
"value": "parameter value",
"parent_template": "source template or null",
"id": value_id,
"name": "parameter name",
},
...
],
"parent_case": { case object as from /case/id }
}
PATCH
Update details of the current job. Note that the author and source case of a job can not be changed after creation.
Arguments
Takes a JSON object of what to replace. Fields that are not included will not be changed.
The largest possible structure is to replace is:
json
{
"name": "New name of the job",
"values": [
{
"name": "parameter name",
"value": "parameter value"
},
...
]
}
Note that the values list is replaced wholesale. So if the
client sends back a shorter list, the removed values will be
deleted.
Return
The following structure is returned.
json
{
"status": "success" | "failed",
"changed": [ "name", "values" ],
"errors": [ "error message" ]
}
Note that the changed field is a list of which fields where successfully changed.
If the request failed then the errors will explain why.
A request will not succeed if there are any errors.
POST
Starts the current job. Does not take any arguments.
Return
The following structure is returned.
json
{
"status": "success" | "failed",
"errors": [ "error message if failed" ]
}
/test/<id>/status
Set the status for a given job to a specfic value.
PUT
Set the status of the given job to the requested.
Arguments
The argument must be the json object:
json
{
"status": "<new status>"
}
where <new status> must be a status from the following list (case insensitive):
- NOT_STARTED
- QUEUED
- FAILED
Return
The following structure is returned.
json
{
"status": "success" | "failed",
"errors": [ "error message if failed" ]
}
/test
This endpoint is used purely for testing the system
POST
This populates the database with some fake data.
Arguments
No arguments are supported
Return
Returns null.
Owner
- Name: The Alan Turing Institute
- Login: alan-turing-institute
- Kind: organization
- Email: info@turing.ac.uk
- Website: https://turing.ac.uk
- Repositories: 477
- Profile: https://github.com/alan-turing-institute
The UK's national institute for data science and artificial intelligence.
GitHub Events
Total
- Issues event: 1
- Issue comment event: 1
Last Year
- Issues event: 1
- Issue comment event: 1
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Roma Klapaukh | r****h@u****k | 98 |
| masonlr | l****n@i****k | 72 |
| Nick Barlow | n****w@t****k | 49 |
| masonlr | m****r@u****u | 26 |
| myyong | m****g@t****k | 21 |
| Nicholas Barlow | n****w@N****l | 3 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: about 1 year ago
All Time
- Total issues: 13
- Total pull requests: 25
- Average time to close issues: 13 days
- Average time to close pull requests: 7 days
- Total issue authors: 3
- Total pull request authors: 4
- Average comments per issue: 1.92
- Average comments per pull request: 0.88
- Merged pull requests: 21
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- klapaukh (7)
- nbarlowATI (4)
- masonlr (2)
- rwood-97 (1)
Pull Request Authors
- masonlr (19)
- klapaukh (2)
- nbarlowATI (2)
- myyong (1)