Skip to content
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

[Feature] Pipeline progress tracking server #1363

Draft
wants to merge 103 commits into
base: develop
Choose a base branch
from

Conversation

anibalsolon
Copy link
Member

@anibalsolon anibalsolon commented Sep 22, 2020

Fixes

Fixes #1279 by @sgiavasis

Description

Alter the monitoring server to a Websocket server, that will use the callback to send to the connected sockets the nodes statuses.

Technical details

During the pipeline execution, we want to monitor the nodes' execution. In order to allow it without needing the user to change C-PAC's code, this PR has a WebSocket server implemented. Different than a regular HTTP server, WS allows the server to push information to the connected clients, essential in an asynchronous setup. If a regular HTTP server was used, the client would need to poll an endpoint to get the current information about execution.

The WS server runs in a different thread than the main C-PAC pipeline builder/runner, so they can be executed in parallel. The way the pipeline runner communicates to the WS about is through two different functions: log_nodes_initial & log_nodes_cb

log_nodes_initial generates the list of existing nodes in a workflow. This is required to at least compute an execution percentage for a workflow run.
log_nodes_cb is the famous callback log, which Nipype calls whenever it has an update about a node.

In both functions, the node info is pushed to a thread-safe queue, so the WS handler can loop through it and send it to the connected client. The queue is only filled if the monitoring is enabled.

When starting a run with the --monitoring flag, the execution hangs until the websocket connects. This is preferred so no data is lost (i.e. C-PAC starts running before the WS connects).

Tests

Docker run with the flag --monitoring and, for the container, -p 8080:8080. It is required to re-build the C-PAC image to install the dependencies.

docker run \
  -it -p 8080:8080 -v `pwd`:/code \
  --entrypoint /code/dev/docker_data/run.py \
  fcpindi/c-pac:latest / /tmp participant --skip_bids_validator \
  --monitoring \
  --data_config_file /code/CPAC/resources/configs/data_config_S3-BIDS-ABIDE.yml --participant_label 0050642 \
  --anat_only --n_cpus 1

It will show a message: [Waiting for monitoring websocket to connect]
Then one can use the following command in another terminal to connect to the WS (how to install websocat):

websocat ws://localhost:8080/log

As C-PAC executes the pipeline, messages in the terminal running websocat will start to pour.

Screenshots

image

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I updated the changelog.
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

sgiavasis and others added 30 commits June 8, 2020 18:45
…eoblique, introduced a more specific NHP preconfig (macaque), included the Yerkes template in cpac templates package.
add a loop based on notch filter order
* Link to latest release notes on docs site (instead of v1.6.0 on GH)
* Add link to CONTRIBUTING.md in developer links section
* Link to versioned docs URLS (the old links redirect, but might as well skip that step)
…CPU is allocated to each participant pipeline.
…bled, and fixed one of the apply warp parallelization concatenation nodes' output connections.
Also update IOError(…'does not exist!') to FileNotFoundError
@anibalsolon anibalsolon changed the title [Feature] Progress tracking [Feature] Pipeline progress tracking server Sep 22, 2020
@anibalsolon anibalsolon marked this pull request as ready for review September 22, 2020 15:09
Copy link
Member

@shnizzedy shnizzedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩 I downloaded the built image from Circle, followed the instructions in the "Test" section above, and it's running and logging locally! Super cool.

@sgiavasis
Copy link
Collaborator

Amazing! And the PR write-up is great.

I'm going to wait until 1.7.1 is cut before merging this into develop.

CPAC/utils/monitoring.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants