-
-
Notifications
You must be signed in to change notification settings - Fork 3
[Feature] Progress tracking and scheduling #1
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
Open
anibalsolon
wants to merge
103
commits into
FCP-INDI:develop
Choose a base branch
from
radiome-lab:feature/progress-tracking
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
103 commits
Select commit
Hold shift + click to select a range
db1073c
add base for the API and a scheduler test
anibalsolon 0bef943
Merge branch 'develop' into feature/progress-tracking
anibalsolon 964e06a
declutering setup.cfg, do not run test for helpers, add helper to path
anibalsolon 6d2ec6a
add dummy test helper for scheduling, rename method, fix status/logs …
anibalsolon fae55e0
use uids instead of actual schedules for references
anibalsolon 75edfe2
test for schedule results
anibalsolon 9c0140b
allow delayed initialization
anibalsolon 82969d3
Fixing inheritance ordering and move backend to the bottom
anibalsolon f1df845
initial test for Docker, using data_settings
anibalsolon e43a27e
data url parser
anibalsolon 3fb3247
docker test for data settings & data config, start on monitoring serv…
anibalsolon 7e5b805
Docker socket used for testing docker log messaging
anibalsolon 05157c2
move scheduling to asyncio
anibalsolon 557106d
docker async fetch logs
anibalsolon 4ba7b72
merge log and docker run into one stream
anibalsolon 93b0213
add conversor to data URI
anibalsolon b394ed6
Re-structure watchers
anibalsolon 2ed0163
add some initial time and actually copy the data config
anibalsolon ec0fdc0
abstract runner as an status yielder, some refactoring on the reporte…
anibalsolon 2056aad
add API and websocket to schedule stuff
anibalsolon c0f2394
fix log messages, add dependency
anibalsolon ec58800
Merge branch 'trunk' into feature/progress-tracking
anibalsolon 97a9596
old, unused code
anibalsolon 02f79cb
use yielded scheduler
anibalsolon 7f861f2
reframe the keyerror as its own key error problem
anibalsolon 59716a1
tag log message
anibalsolon e0d7dee
do not resend the schedule id, since it is already in the message
anibalsolon df29e0d
deal with s3 bids dir, and generate a data config for it
anibalsolon ae9a938
comment out unimplemented results
anibalsolon 58956f7
add new req for app dir, start sql db, add semaphore to limit number …
anibalsolon 67685e6
use failure tag, use RunStatus on tests, fix test logs access
anibalsolon cd80278
Merge branch 'primary' into feature/progress-tracking
anibalsolon 4b39b0e
add singularity support, generalize code to containers, simulate erro…
anibalsolon bf890fb
ignore singularity images
anibalsolon 8b86b4d
add default value when there is no folder i.e. data config used
anibalsolon 6dac401
convert to image usage
anibalsolon 9517b30
abstracting code to permute backends for testing
anibalsolon acd2a7c
add missing dependency
anibalsolon 769a743
starting up with slurm
anibalsolon 06c1886
slurm cluster for tests
anibalsolon 7ad6269
removing unused requirements
anibalsolon 324d96d
parametrize args
anibalsolon 0d64677
guarantee queue is cancelled
anibalsolon 6af8912
add schedule to messages, fix singularitu configs for networking
anibalsolon 589009e
new endpoints to get results, status & metadata; allow participant sc…
anibalsolon d4e6d57
overwrite pre and post- will happen on the slurm side; add ret code
anibalsolon 6ed4183
update dummy backend
anibalsolon 4ed89aa
remove slurm old test
anibalsolon e55f8b7
test traverse deep objects
anibalsolon 0a52fb0
add crash and log support
anibalsolon 24416af
add unwatch to close sockets, handle not found schedules, await for t…
anibalsolon 0eebde9
add result messages
anibalsolon f5aada5
unused args
anibalsolon ef7ecd6
show # of running tasks
anibalsolon 665bce9
lint
anibalsolon bfe3789
spacious
anibalsolon f6fe76c
add original relative name to results
anibalsolon bbba016
allow log files
anibalsolon f96651d
parametrize backend on server response, add backend id for further mu…
anibalsolon ec8033d
better handling ws errors, making sure the tasks get cancelled
anibalsolon 82fc59c
rework slurm testing, use current running cluster to perform tests
anibalsolon a7ca313
undo change on changelog
anibalsolon 1f64e08
cleaning up old code
anibalsolon 4b0a639
use the latest C-PAC image
anibalsolon 48aa678
unused var
anibalsolon 2c503db
not used
anibalsolon b4bf5fb
fix 3.6 errors
anibalsolon ae5372d
HAHA wat
anibalsolon 67b4342
do not download the whole C-PAC
anibalsolon a05d612
add missing dependencies
anibalsolon e368654
upgrade dependency
anibalsolon 95d237e
updates to set a default behavior when slurm_key and slurm_control ar…
3a3c622
added service file to start cpac-api on system start
64b7ffe
start script for creating a cpac cluster ami
909d55f
enh: tools for development
anibalsolon 43c4d86
STASH
YiranCdr c58e848
Merge remote-tracking branch 'origin/feature/progress-tracking' into …
YiranCdr 818276f
Feature: container params
YiranCdr 076dd2c
Minor fix
YiranCdr b6cbfdd
Feature: authKey
YiranCdr d791b60
minor fix
YiranCdr 2be08ae
enh: use real data to report node execution
anibalsolon 4a82024
STASH - ALL POST
YiranCdr 4fa25da
Merge remote-tracking branch 'origin/feature/ys-dev' into feature/ys-dev
YiranCdr 3da61db
fix: add more logs, replace fixed image on template
anibalsolon 4a5da25
fix: refactor auth
anibalsolon 964f48f
fix: allow cors
anibalsolon 8f2d1e0
fix: output folder for data config
anibalsolon 76c435a
fix: match cpac new output
anibalsolon 776800e
debounce
YiranCdr 32fc778
Merge remote-tracking branch 'origin/feature/ys-dev' into feature/ys-dev
YiranCdr 82b7e0a
debounce 1/2
YiranCdr 3450eaa
auth token strip()
YiranCdr f8ccd29
post -> get
YiranCdr 351a3a1
fix: add logs to slurm
anibalsolon b428b25
fix: exec date and exit
anibalsolon 616143d
fix: more logs
anibalsolon 60549b3
fix: run command in real shell
anibalsolon 80a6ed0
Merge remote-tracking branch 'origin/feature/anibalsolon-dev' into fe…
YiranCdr 370e378
Fix: pull-request fixes.
YiranCdr a2500d9
Merge branch 'feature/ys-dev' into feature/progress-tracking
YiranCdr 2dc24ce
fix: method name
anibalsolon 77a46a0
fix: method name
anibalsolon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [Unit] | ||
| Description=API to allow CPAC Dashboard to communicate with CPAC CLI (e.g. for cluster) | ||
| After=sshd.service | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| User=ubuntu | ||
| ExecStart=/home/ubuntu/miniconda3/bin/python -m cpac.api scheduler --backend slurm \ | ||
| --singularity-image /shared/C-PAC.simg --slurm-host localhost:22 --slurm-username ubuntu | ||
| WorkingDirectory=/home/ubuntu | ||
|
|
||
| [Install] | ||
| Alias=cpac-api.service | ||
| WantedBy=mult-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [pytest] | ||
| log_cli = 1 | ||
| log_cli_level = INFO | ||
| log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) | ||
| log_cli_date_format=%Y-%m-%d %H:%M:%S | ||
| addopts = -s -v | ||
|
|
||
| testpaths = tests | ||
| norecursedirs = | ||
| dist | ||
| build | ||
| .tox | ||
| tests/helpers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,4 @@ setuptools | |
| spython >= 0.0.81 | ||
| tabulate >= 0.8.6 | ||
| tornado | ||
| websocket-client | ||
| appdirs == 1.4.4 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| import argparse | ||
| import sys | ||
| import logging | ||
| import random | ||
| import string | ||
|
|
||
| from .. import __version__ | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class ExtendAction(argparse.Action): | ||
| def __call__(self, parser, namespace, values, option_string=None): | ||
| items = (getattr(namespace, self.dest) or []) + values | ||
| items = [x for n, x in enumerate(items) if x not in items[:n]] | ||
| setattr(namespace, self.dest, items) | ||
|
|
||
|
|
||
| def address(str): | ||
| addr, port = str.split(':') | ||
| port = int(port) | ||
| return addr, port | ||
|
|
||
|
|
||
| def parse_args(args): | ||
| parser = argparse.ArgumentParser( | ||
| description='cpac: a Python package that simplifies using C-PAC. CCs development version' | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| '--version', | ||
| action='version', | ||
| version='cpac {ver}'.format(ver=__version__) | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| '-v', | ||
| '--verbose', | ||
| dest="loglevel", | ||
| help="set loglevel to INFO", | ||
| action='store_const', | ||
| const=logging.INFO | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| '-vv', | ||
| '--very-verbose', | ||
| dest="loglevel", | ||
| help="set loglevel to DEBUG", | ||
| action='store_const', | ||
| const=logging.DEBUG | ||
| ) | ||
|
|
||
| subparsers = parser.add_subparsers(dest='command') | ||
|
|
||
| scheduler_parser = subparsers.add_parser('scheduler') | ||
| scheduler_parser.add_argument('--address', action='store', type=address, default='localhost:3333') | ||
| scheduler_parser.add_argument('--proxy', action='store_true') | ||
| scheduler_parser.add_argument('--backend', choices=['docker', 'singularity', 'slurm'], default='singularity') | ||
|
|
||
| scheduler_parser.add_argument('--singularity-image', nargs='?') | ||
|
|
||
| scheduler_parser.add_argument('--docker-image', nargs='?') | ||
|
|
||
| scheduler_parser.add_argument('--slurm-host', nargs='?') | ||
| scheduler_parser.add_argument('--slurm-username', nargs='?') | ||
| scheduler_parser.add_argument('--slurm-key', nargs='?') | ||
| scheduler_parser.add_argument('--slurm-control', nargs='?', | ||
| default=f'~/.ssh/{"".join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(24))}') | ||
| scheduler_parser.add_argument('--slurm-pip-install', nargs='?') | ||
| scheduler_parser.add_argument('--slurm-singularity-image', nargs='?') | ||
|
|
||
| parsed = parser.parse_args(args) | ||
|
|
||
| return parsed | ||
|
|
||
|
|
||
| def setup_logging(loglevel): | ||
| logformat = "[%(asctime)s] %(levelname)s:%(name)s:%(message)s" | ||
| logging.basicConfig(level=loglevel, stream=sys.stdout, | ||
| format=logformat, datefmt="%Y-%m-%d %H:%M:%S") | ||
|
|
||
|
|
||
| async def start(args): | ||
| from cpac.api.server import start | ||
| from cpac.api.backends import available_backends | ||
| from cpac.api.scheduling import Scheduler | ||
| from cpac.api.authKey import AuthKey | ||
|
|
||
| print("Running server") | ||
| print("Auth key: ", AuthKey.generate_key()) | ||
|
|
||
| backend = args.backend | ||
| cmd_args = vars(args) | ||
|
|
||
| backend = available_backends[backend]( | ||
| id=backend, | ||
| **{ | ||
| arg.split('_', 1)[1]: val | ||
| for arg, val in cmd_args.items() | ||
| if arg.startswith(backend) | ||
| } | ||
| ) | ||
|
|
||
| async with Scheduler(backend, proxy=args.proxy) as scheduler: | ||
| await start(args.address, scheduler) | ||
| await scheduler | ||
|
|
||
|
|
||
| def main(args): | ||
| command = args[0] | ||
| args = parse_args(args[1:]) | ||
| setup_logging(args.loglevel) | ||
|
|
||
| if args.command == 'scheduler': | ||
| import asyncio | ||
| asyncio.run(start(args)) | ||
|
|
||
|
|
||
| def run(): | ||
| main(sys.argv) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import uuid | ||
|
|
||
|
|
||
| class AuthKey: | ||
| key = None | ||
|
|
||
| @staticmethod | ||
| def generate_key(): | ||
| if not AuthKey.key: | ||
| AuthKey.key = str(uuid.uuid1()) | ||
| return AuthKey.key | ||
|
|
||
| @staticmethod | ||
| def get_key(): | ||
| return AuthKey.key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from .docker import DockerBackend | ||
| from .singularity import SingularityBackend | ||
| from .slurm import SLURMBackend | ||
|
|
||
| available_backends = { | ||
| 'docker': DockerBackend, | ||
| 'singularity': SingularityBackend, | ||
| 'slurm': SLURMBackend, | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.