Skip to main content

A Django application to manage long running job submission, including starting the job, saving logs, and storing results.

Project description

Django Remote Submission

A Django application to manage long running job submission, including starting the job, saving logs, and storing results.


  • Able to connect to any server via SSH user/password or key-based authentication.

  • Able to transfer and launch any script in the remote server (e.g. python or bash scripts).

  • Able to capture and receive logs and write them to a database in realtime.

  • Able to return any modified files from the remote server.

  • Uses WebSockets to notify the Web Client of the Job status: initial, submitted, success or failure.

  • Uses WebSockets to provide Job Log (standard output and standard error) in real time to the Web Client.


The full documentation is at


Install Django Remote Submission:

pip install django-remote-submission

Then use it in a project:

from django_remote_submission.models import Server, Job
from django_remote_submission.tasks import submit_job_to_server

server = Server.objects.get_or_create(
    title='My Server Title',

python2_interpreter = Interpreter.objects.get_or_create(
    name = 'python2',
    path = '/usr/bin/python2.7 -u',

python3_interpreter = Interpreter.objects.get_or_create(
    name = 'python3',
    path = '/usr/bin/python3.5 -u',


job = Job.objects.get_or_create(
    title='My Job Title',
    program='print("hello world")',

# Using delay calls celery:
modified_files = submit_job_to_server.delay(,

For testing, sometimes is useful to bypass the remote server and run the task in the local computer. For this, the submit_job_to_server routine can be called with the argument remote=False. The function above would be:

modified_files = submit_job_to_server.delay(,

Note that it stills use Celery. It just ignores the password passed as argument.

To avoid storing the password one can deploy the client public key in the server.

from django_remote_submission.tasks import copy_key_to_server

    public_key_filename=None, # finds it automaticaly

And it can be deleted once the session is finished:

from django_remote_submission.tasks import delete_key_from_server


Running the Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ make test

Some of the tests use a test server to check the functional aspects of the library. Specifically, it will try to connect to the server multiple times, run some programs, and check that their output is correct.

To run those tests as well, copy the .env.base file to .env and modify the variables as needed. If this file has not been set up, then those tests will be skipped, but it won’t affect the success or failure of the tests.

Running tests independtely, e.g.:

pytest -v tests/
pytest -v tests/

Running the Example

Set the example/.env file. Copy or rename example/.env.base and fill in the details of the remote machine where the sshd server is running:


Set up the example’s virtualenv:

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

Launch Redis:


Launch Celery:

cd example
celery -A server.celery worker --loglevel=info

Launch Django:

cd example
./ makemigrations
./ migrate
./ loaddata fixtures/initial_data.json
# You may want to create another user:
# python createsuperuser
./ runserver

Open in the browser one of the links below. The password for admin is admin123 unless you prefer to use the created password:

# For the Admin Interface
# For the REST API
# To test Job creation with live status update

Web Interface

The app provides two web sockets to see in real time the Job Status and the Log associated to a Job.

Those are defined in


The example app comes with the Live Job Status and Live Log examples. See:

# Jobs
# Job 123 Log

Both files:


Have the client side web socket code to interact with the django-remote-submission app. Also to include the Live information on a web app it is worth looking at the celery configuration:


and the WebSockets routing:


Useful notes

The Results files are stored in MEDIA. So add to your setings something similar to:

MEDIA_URL = '/media/'
MEDIA_ROOT = '../dist/media'

To make media available in DEBUG mode, you might want to add to the main

if settings.DEBUG:
    # Serving files uploaded by a user during development
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Tools used in rendering this package:

This research used resources at the High Flux Isotope Reactor and Spallation Neutron Source, a DOE Office of Science User Facility operated by the Oak Ridge National Laboratory.


2.1.0 (2018-05-18)

  • Added task to only copy the job file. It does not run it.

2.0.0 (2018-04-19)

  • Uses channels 2.0. Only supports python 3.

1.2.1 (2017-11-13)

  • Corrected Channels version in requirements.

1.2 (2017-11-13)

1.1.6 (2017-08-23)

  • Local Wrapper uses process.comunicate

1.1.5 (2017-08-23)

  • Local Wrapper does no support Live Log ever.

1.1.4 (2017-08-19)

  • Fixed CI tests.

1.1.3 (2017-08-19)

  • Local wrapper runs in all DBs without truncation.

1.1.2 (2017-08-18)

  • Fixed Local wrapper truncate the log.

1.1.1 (2017-08-18)

  • Fix issue with python 2.7

1.1.0 (2017-08-18)

  • Creates the remote directory if it does not exist.

1.0.1 (2017-08-18)

  • Updated DOC with the remote argument.

1.0.0 (2017-08-17)

  • All ready to be released

  • Tasks have an attribute to run locally or remotelly.

0.13.0 (2017-08-17)

  • LocalWrapper and RemoteWrapper are in the wrapper package.

0.12.0 (2017-08-16)

  • Improved documentation

0.11.2 (2017-08-15)

  • Publication ready

0.2.0 (2016-11-17)

  • Add django admin interface.

  • Add migrations folder.

  • Add log policies for submitting tasks.

  • Add return value for modified files.

0.1.1 (2016-11-15)

  • Add port number to Server model.

  • Add task to submit jobs.

  • Add status updates to task.

  • Fix unicode error when submitting jobs.

  • Fix verbose/related names for models.

0.1.0 (2016-11-08)

  • First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-remote-submission-2.1.0.tar.gz (28.9 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page