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

WIP: Azure Batch integration #533

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e6842dd
Added default remote provider support for AZ
Apr 8, 2020
4949bfe
Renamed --az-config to --az-store-credentials
Apr 20, 2020
ece6533
Docs improvement for --az-store-credentials
Apr 23, 2020
93b90d7
Initial commit for az_batch work
Apr 24, 2020
a4d92bc
Fixed wrong handling of empty az_store_credentials
Apr 28, 2020
419ce4a
Merge branch 'master' into az-default-remote
May 6, 2020
1b943f3
Minor cleanup
May 6, 2020
76d1438
Pylint cleanup of AzBlob
May 8, 2020
a901a36
Merge branch 'az-default-remote' into azbatch
May 12, 2020
8282257
WIP: Added AZ Batch init and shutdown to executors
May 13, 2020
8e14441
Fixed broken backward compat between AzBlob and AzureStorage
May 13, 2020
9116f01
Merge branch 'az-default-remote' into azbatch
May 13, 2020
8ef1f11
Prefixed all AZ Batch config vars with BATCH
May 13, 2020
7e3b12d
Merge branch 'master' into az-default-remote
johanneskoester May 21, 2020
5fcac9f
Black formatting and removal of unnecessary AzureStorage support
May 21, 2020
c76dc78
Fixed bug trigger by missing AZ envvars
May 21, 2020
2dcf809
Merge branch 'az-default-remote' of https://github.com/andreas-wilm/s…
May 21, 2020
3243c69
Added black formatting for __init__.py
May 21, 2020
faa0328
AzBlob now using newer azure-storage-blob module
Jun 6, 2020
9ddeb20
AzBlob: added check if blob needs deletion before upload
Jun 7, 2020
b210b91
Merge branch 'az-default-remote' into azbatch
Jun 9, 2020
660045c
Fixed merging error and typo
Jun 10, 2020
d03052a
Added AKS tutorial
Jun 15, 2020
86711f4
Merge branch 'az-default-remote' into azbatch
Jun 23, 2020
48a20fc
Moved AzBatch executor from executors/__init__ to its own file
Jul 27, 2020
0f260b6
WIP: wait_for_jobs done
Jul 27, 2020
fdb6f9b
WIP: resource upload, container use, task status
Jul 28, 2020
e26914f
WIP: fixed commandline, container now arg, resource file per task
Jul 29, 2020
5a99293
Fixed mixed handdown of container
andreas-wilm Jul 30, 2020
8e367d6
Correctly using envvars and running as admin user
andreas-wilm Jul 30, 2020
95f8a27
Black formatting
andreas-wilm Jul 30, 2020
98b49c8
Added task retry (hardcoded)
andreas-wilm Jul 30, 2020
ff623ba
Clean up improvements (cancel and shutdown) and misc
Aug 4, 2020
73841f1
Merge branch 'master' into azbatch
johanneskoester Sep 9, 2020
3cfeabf
Merge branch 'master' into azbatch
johanneskoester Sep 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions environment.yml
@@ -0,0 +1,40 @@
channels:
- conda-forge
- bioconda
dependencies:
- python >=3.5
- boto3
- datrie
- moto >=1.0.1
- httpretty
- wrapt
- pyyaml
- ftputil
- pysftp
- requests
- dropbox
- appdirs
- pytools
- docutils
- psutil
- pandas
- nomkl
- google-cloud-storage
- azure-storage
- azure-storage-common
- azure-batch
- ratelimiter
- configargparse
- appdirs
- python-irodsclient
- jsonschema
- networkx
- pygraphviz
# needed by graphviz
- xorg-libxrender
- xorg-libxpm
- gitpython
- pygments
- imagemagick
- nbformat
- toposort
43 changes: 41 additions & 2 deletions snakemake/__init__.py
Expand Up @@ -161,6 +161,7 @@ def snakemake(
show_failed_logs=False,
keep_incomplete=False,
messaging=None,
az_batch_configfile=None,
edit_notebook=None,
envvars=None,
overwrite_groups=None,
Expand Down Expand Up @@ -282,6 +283,7 @@ def snakemake(
log_handler (function): redirect snakemake output to this custom log handler, a function that takes a log message dictionary (see below) as its only argument (default None). The log message dictionary for the log handler has to following entries:
keep_incomplete (bool): keep incomplete output files of failed jobs
edit_notebook (object): "notebook.Listen" object to configuring notebook server for interactive editing of a rule notebook. If None, do not edit.
az_batch_configfile (str): Azure Batch configuration file
scheduler (str): Select scheduling algorithm (default ilp)
overwrite_groups (dict): Rule to group assignments (default None)
group_components (dict): Number of connected components given groups shall span before being split up (1 by default if empty)
Expand Down Expand Up @@ -334,6 +336,10 @@ def snakemake(
immediate_submit and notemp
), "immediate_submit has to be combined with notemp (it does not support temp file handling)"

az_batch = False
if az_batch_configfile:
az_batch = True

if tibanna:
assume_shared_fs = False
default_remote_provider = "S3"
Expand All @@ -360,6 +366,11 @@ def snakemake(
tibanna_config_dict.update({k: v})
tibanna_config = tibanna_config_dict

if az_batch:
# TODO check that other modes are not activated, e.g. tibanna, drmaa etc
assume_shared_fs = False
default_remote_provider = "AzBlob"

# Google Cloud Life Sciences API uses compute engine and storage
if google_lifesciences:
assume_shared_fs = False
Expand All @@ -375,7 +386,7 @@ def snakemake(
if updated_files is None:
updated_files = list()

if cluster or cluster_sync or drmaa or tibanna or kubernetes or google_lifesciences:
if cluster or cluster_sync or drmaa or tibanna or kubernetes or google_lifesciences or az_batch:
cores = None
else:
nodes = None
Expand All @@ -396,7 +407,7 @@ def snakemake(
cluster_config_content = dict()

run_local = not (
cluster or cluster_sync or drmaa or kubernetes or tibanna or google_lifesciences
cluster or cluster_sync or drmaa or kubernetes or tibanna or google_lifesciences or az_batch
)
if run_local:
if not dryrun:
Expand Down Expand Up @@ -492,6 +503,11 @@ def snakemake(

logger.setup_logfile()

if az_batch_configfile:
az_batch_config = load_configfile(az_batch_configfile)
else:
az_batch_config = None

try:
# handle default remote provider
_default_remote_provider = None
Expand Down Expand Up @@ -551,6 +567,7 @@ def snakemake(
resources=resources,
edit_notebook=edit_notebook,
envvars=envvars,
az_batch_config=az_batch_config,
)
success = True

Expand Down Expand Up @@ -645,6 +662,7 @@ def snakemake(
cluster_status=cluster_status,
max_jobs_per_second=max_jobs_per_second,
max_status_checks_per_second=max_status_checks_per_second,
az_batch_configfile=az_batch_configfile,
overwrite_groups=overwrite_groups,
group_components=group_components,
)
Expand Down Expand Up @@ -2078,6 +2096,13 @@ def get_argument_parser(profile=None):
"fallback for rules which don't define environment modules.",
)

group_env_modules = parser.add_argument_group("AZURE")

group_env_modules.add_argument(
"--az-batch-configfile",
help="Azure Batch config file",
)

return parser


Expand Down Expand Up @@ -2131,6 +2156,7 @@ def adjust_path(f):
or (args.tibanna and not args.default_resources)
or (args.google_lifesciences and not args.default_resources)
):
# FIXME do we need default resources for az_batch as well?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that would be good in any case.

args.default_resources = [
"mem_mb=max(2*input.size_mb, 1000)",
"disk_mb=max(2*input.size_mb, 1000)",
Expand All @@ -2154,6 +2180,7 @@ def adjust_path(f):
or args.google_lifesciences
or args.kubernetes
or args.tibanna
or args.az_batch_configfile
or args.list_code_changes
or args.list_conda_envs
or args.list_input_changes
Expand Down Expand Up @@ -2240,6 +2267,17 @@ def adjust_path(f):
)
sys.exit(1)

if args.az_batch_configfile and (
not args.default_remote_provider or not args.default_remote_prefix
):
print(
"Error: --az-batch-configfile must be combined with "
"--default-remote-provider AzBlob and --default-remote-prefix to "
"provide a bucket name",
file=sys.stderr,
)
sys.exit(1)

if args.kubernetes and (
not args.default_remote_provider or not args.default_remote_prefix
):
Expand Down Expand Up @@ -2511,6 +2549,7 @@ def open_browser():
overwrite_groups=overwrite_groups,
group_components=group_components,
log_handler=log_handler,
az_batch_configfile=args.az_batch_configfile,
)

if args.runtime_profile:
Expand Down
11 changes: 7 additions & 4 deletions snakemake/executors/__init__.py
Expand Up @@ -7,9 +7,9 @@
import sys
import contextlib
import time
import datetime
#import datetime
import json
import textwrap
#import textwrap
import stat
import shutil
import shlex
Expand All @@ -19,10 +19,10 @@
import signal
import tempfile
from functools import partial
from itertools import chain
#from itertools import chain
from collections import namedtuple
from snakemake.io import _IOFile
import random
#import random
import base64
import uuid
import re
Expand Down Expand Up @@ -2207,3 +2207,6 @@ def run_wrapper(
write_benchmark_records(bench_records, benchmark)
except (Exception, BaseException) as ex:
raise WorkflowError(ex)