Skip to content

Commit

Permalink
Merge pull request #381 from JrGoodle/s3-coverage
Browse files Browse the repository at this point in the history
Upload coverage results to s3
  • Loading branch information
JrGoodle committed Nov 10, 2017
2 parents 5e23bfc + f642722 commit 06a21db
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 84 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ parallel = True
omit =
# omit everything in /usr
/usr/*

[paths]
source =
clowder/clowder
/home/travis/build/*/clowder/clowder
4 changes: 2 additions & 2 deletions clowder/clowder/cli/branch_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.clowder_utils import (
filter_groups,
filter_projects_on_project_names,
filter_projects,
options_help_message,
run_group_command,
run_project_command
Expand Down Expand Up @@ -72,6 +72,6 @@ def _branch(self):
run_group_command(group, self.app.pargs.skip, 'branch', local=local, remote=remote)
return

projects = filter_projects_on_project_names(CLOWDER_CONTROLLER.groups, self.app.pargs.projects)
projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects)
for project in projects:
run_project_command(project, self.app.pargs.skip, 'branch', local=local, remote=remote)
4 changes: 2 additions & 2 deletions clowder/clowder/cli/checkout_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.clowder_utils import (
filter_groups,
filter_projects_on_project_names,
filter_projects,
options_help_message,
run_group_command,
run_project_command
Expand Down Expand Up @@ -65,6 +65,6 @@ def _checkout(self):
run_group_command(group, self.app.pargs.skip, 'checkout', self.app.pargs.branch[0])
return

projects = filter_projects_on_project_names(CLOWDER_CONTROLLER.groups, self.app.pargs.projects)
projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects)
for project in projects:
run_project_command(project, self.app.pargs.skip, 'checkout', self.app.pargs.branch[0])
6 changes: 3 additions & 3 deletions clowder/clowder/cli/clean_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.clowder_utils import (
filter_groups,
filter_projects_on_project_names,
filter_projects,
options_help_message,
run_group_command,
run_project_command
Expand Down Expand Up @@ -112,7 +112,7 @@ def _clean(clowder, group_names, **kwargs):
run_group_command(group, skip, 'clean', args=args, recursive=recursive)
return

projects = filter_projects_on_project_names(clowder.groups, project_names)
projects = filter_projects(clowder.groups, project_names=project_names)
for project in projects:
run_project_command(project, skip, 'clean', args=args, recursive=recursive)

Expand All @@ -139,6 +139,6 @@ def _clean_all(clowder, group_names, **kwargs):
run_group_command(group, skip, 'clean_all')
return

projects = filter_projects_on_project_names(clowder.groups, project_names)
projects = filter_projects(clowder.groups, project_names=project_names)
for project in projects:
run_project_command(project, skip, 'clean_all')
4 changes: 2 additions & 2 deletions clowder/clowder/cli/diff_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.clowder_utils import (
filter_groups,
filter_projects_on_project_names,
filter_projects,
options_help_message,
run_group_command,
run_project_command
Expand Down Expand Up @@ -65,6 +65,6 @@ def _diff(self):
run_group_command(group, [], 'diff')
return

projects = filter_projects_on_project_names(CLOWDER_CONTROLLER.groups, self.app.pargs.projects)
projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects)
for project in projects:
run_project_command(project, [], 'diff')
76 changes: 44 additions & 32 deletions clowder/clowder/cli/parallel_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from clowder.util.progress import Progress
from clowder.util.clowder_utils import (
filter_groups,
filter_projects_on_group_names,
filter_projects_on_project_names,
filter_projects,
print_parallel_groups_output,
print_parallel_projects_output,
run_group_command,
Expand Down Expand Up @@ -122,7 +121,7 @@ def sig_int(signal_num, frame):
def forall(clowder, command, ignore_errors, group_names, **kwargs):
"""Runs script in project directories specified
.. py:function:: forall_script(script_command, ignore_errors, group_names, project_names=None, skip=[], parallel=False)
.. py:function:: forall_script(clowder, command, ignore_errors, group_names, project_names=None, skip=[], parallel=False)
:param ClowderController clowder: ClowderController instance
:param list[str] command: Command or script and optional arguments
Expand All @@ -139,10 +138,7 @@ def forall(clowder, command, ignore_errors, group_names, **kwargs):
skip = kwargs.get('skip', [])
parallel = kwargs.get('parallel', False)

if project_names is None:
projects = filter_projects_on_group_names(clowder.groups, group_names)
else:
projects = filter_projects_on_project_names(clowder.groups, project_names)
projects = filter_projects(clowder.groups, group_names=group_names, project_names=project_names)

if parallel:
_forall_parallel([" ".join(command)], skip, ignore_errors, projects)
Expand All @@ -155,7 +151,7 @@ def forall(clowder, command, ignore_errors, group_names, **kwargs):
def herd(clowder, group_names, **kwargs):
"""Clone projects or update latest from upstream
.. py:function:: herd(group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[], protocol=None)
.. py:function:: herd(clowder, group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[], protocol=None)
:param ClowderController clowder: ClowderController instance
:param list[str] group_names: Group names to herd
Expand Down Expand Up @@ -186,7 +182,7 @@ def herd(clowder, group_names, **kwargs):
depth=depth, rebase=rebase, protocol=protocol)
return

projects = filter_projects_on_project_names(clowder.groups, project_names)
projects = filter_projects(clowder.groups, project_names=project_names)
validate_projects(projects)
for project in projects:
run_project_command(project, skip, 'herd', branch=branch, tag=tag,
Expand All @@ -196,7 +192,7 @@ def herd(clowder, group_names, **kwargs):
def herd_parallel(clowder, group_names, **kwargs):
"""Clone projects or update latest from upstream in parallel
.. py:function:: herd_parallel(group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[], protocol=None)
.. py:function:: herd_parallel(clowder, group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[], protocol=None)
:param ClowderController clowder: ClowderController instance
:param list[str] group_names: Group names to herd
Expand All @@ -220,15 +216,9 @@ def herd_parallel(clowder, group_names, **kwargs):
protocol = kwargs.get('protocol', None)

print(' - Herd projects in parallel\n')
if project_names is None:
groups = filter_groups(clowder.groups, group_names)
validate_groups(groups)
projects = filter_projects_on_group_names(clowder.groups, group_names)
print_parallel_groups_output(groups, skip)
else:
projects = filter_projects_on_project_names(clowder.groups, project_names)
validate_projects(projects)
print_parallel_projects_output(projects, skip)
_validate_print_output(clowder, group_names, project_names=project_names, skip=skip)

projects = filter_projects(clowder.groups, group_names=group_names, project_names=project_names)

for project in projects:
if project.name in skip:
Expand All @@ -243,7 +233,7 @@ def herd_parallel(clowder, group_names, **kwargs):
def reset(clowder, group_names, **kwargs):
"""Reset project branches to upstream or checkout tag/sha as detached HEAD
.. py:function:: reset(group_names, timestamp_project=None, parallel=False, project_names=None, skip=[])
.. py:function:: reset(clowder, group_names, timestamp_project=None, parallel=False, project_names=None, skip=[])
:param ClowderController clowder: ClowderController instance
:param list[str] group_names: Group names to reset
Expand Down Expand Up @@ -274,7 +264,7 @@ def reset(clowder, group_names, **kwargs):
run_group_command(group, skip, 'reset', timestamp=timestamp)
return

projects = filter_projects_on_project_names(clowder.groups, project_names)
projects = filter_projects(clowder.groups, project_names=project_names)
validate_projects(projects)
for project in projects:
run_project_command(project, skip, 'reset', timestamp=timestamp)
Expand All @@ -291,7 +281,7 @@ def sync(clowder, project_names, rebase=False, parallel=False):
:param Optional[bool] parallel: Whether command is being run in parallel, affects output
"""

projects = filter_projects_on_project_names(clowder.groups, project_names)
projects = filter_projects(clowder.groups, project_names=project_names)
if parallel:
_sync_parallel(projects, rebase=rebase)
return
Expand Down Expand Up @@ -333,7 +323,7 @@ def _forall_parallel(commands, skip, ignore_errors, projects):
def _reset_parallel(clowder, group_names, **kwargs):
"""Reset project branches to upstream or checkout tag/sha as detached HEAD in parallel
.. py:function:: _reset_parallel(group_names, timestamp_project=None, project_names=None, skip=[])
.. py:function:: _reset_parallel(clowder, group_names, timestamp_project=None, project_names=None, skip=[])
:param ClowderController clowder: ClowderController instance
:param list[str] group_names: Group names to reset
Expand All @@ -353,15 +343,9 @@ def _reset_parallel(clowder, group_names, **kwargs):
if timestamp_project:
timestamp = clowder.get_timestamp(timestamp_project)

if project_names is None:
groups = filter_groups(clowder.groups, group_names)
validate_groups(groups)
projects = filter_projects_on_group_names(clowder.groups, group_names)
print_parallel_groups_output(groups, skip)
else:
projects = filter_projects_on_project_names(clowder.groups, project_names)
validate_projects(projects)
print_parallel_projects_output(projects, skip)
_validate_print_output(clowder, group_names, project_names=project_names, skip=skip)

projects = filter_projects(clowder.groups, group_names=group_names, project_names=project_names)

for project in projects:
if project.name in skip:
Expand Down Expand Up @@ -389,6 +373,34 @@ def _sync_parallel(projects, rebase=False):
pool_handler(len(projects))


def _validate_print_output(clowder, group_names, **kwargs):
"""Validate projects/groups and print output
.. py:function:: _validate_print_output(clowder, group_names, project_names=None, skip=[])
:param ClowderController clowder: ClowderController instance
:param list[str] group_names: Group names to validate/print
Keyword Args:
project_names (list[str]): Project names to validate/print
skip (list[str]): Project names to skip
"""

project_names = kwargs.get('project_names', None)
skip = kwargs.get('skip', [])

if project_names is None:
groups = filter_groups(clowder.groups, group_names)
validate_groups(groups)
projects = filter_projects(clowder.groups, group_names=group_names)
print_parallel_groups_output(groups, skip)
return

projects = filter_projects(clowder.groups, project_names=project_names)
validate_projects(projects)
print_parallel_projects_output(projects, skip)


# Disable warnings shown by pylint for catching too general exception
# pylint: disable=W0703

Expand Down
4 changes: 2 additions & 2 deletions clowder/clowder/cli/prune_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
existing_branch_groups,
existing_branch_projects,
filter_groups,
filter_projects_on_project_names,
filter_projects,
options_help_message,
run_group_command,
run_project_command,
Expand Down Expand Up @@ -129,7 +129,7 @@ def _prune(clowder, group_names, branch, **kwargs):
_prune_groups(groups, branch, skip=skip, force=force, local=local, remote=remote)
return

projects = filter_projects_on_project_names(clowder.groups, project_names)
projects = filter_projects(clowder.groups, project_names=project_names)
validate_projects(projects)
_prune_projects(projects, branch, skip=skip, force=force, local=local, remote=remote)

Expand Down
4 changes: 2 additions & 2 deletions clowder/clowder/cli/start_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.clowder_utils import (
filter_groups,
filter_projects_on_project_names,
filter_projects,
options_help_message,
run_group_command,
run_project_command,
Expand Down Expand Up @@ -85,7 +85,7 @@ def _start_branches(self, tracking):
run_group_command(group, self.app.pargs.skip, 'start', self.app.pargs.branch, tracking)
return

projects = filter_projects_on_project_names(CLOWDER_CONTROLLER.groups, self.app.pargs.projects)
projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects)
validate_projects(projects)
for project in projects:
run_project_command(project, self.app.pargs.skip, 'start', self.app.pargs.branch, tracking)
4 changes: 2 additions & 2 deletions clowder/clowder/cli/stash_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.clowder_utils import (
filter_groups,
filter_projects_on_project_names,
filter_projects,
options_help_message,
run_group_command,
run_project_command
Expand Down Expand Up @@ -70,6 +70,6 @@ def _stash(self):
run_group_command(group, self.app.pargs.skip, 'stash')
return

projects = filter_projects_on_project_names(CLOWDER_CONTROLLER.groups, self.app.pargs.projects)
projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects)
for project in projects:
run_project_command(project, self.app.pargs.skip, 'stash')
38 changes: 24 additions & 14 deletions clowder/clowder/util/clowder_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os

import clowder.util.formatting as fmt
from clowder import ROOT_DIR
from clowder.error.clowder_exit import ClowderExit


Expand Down Expand Up @@ -37,6 +38,20 @@ def existing_branch_projects(projects, branch, is_remote):
return any([p.existing_branch(branch, is_remote=is_remote) for p in projects])


def get_clowder_yaml_import_path(import_name):
"""Return path to imported clowder.yaml file
:param str import_name: Name of imported clowder.yaml
:return: Path to imported clowder.yaml file
:rtype: str
"""

if import_name == 'default':
return os.path.join(ROOT_DIR, '.clowder', 'clowder.yaml')

return os.path.join(ROOT_DIR, '.clowder', 'versions', import_name, 'clowder.yaml')


def filter_groups(groups, names):
"""Filter groups based on given group names
Expand All @@ -49,28 +64,23 @@ def filter_groups(groups, names):
return [g for g in groups if g.name in names]


def filter_projects_on_project_names(groups, names):
"""Filter projects based on given project names
def filter_projects(groups, group_names=None, project_names=None):
"""Filter projects based on given project or group names
:param list[Group] groups: Groups to filter
:param list[str] names: Project names to match against
:param list[str] group_names: Group names to match against
:param list[str] project_names: Project names to match against
:return: List of projects in groups matching given names
:rtype: list[Project]
"""

return [p for g in groups for p in g.projects if p.name in names]
if project_names is not None:
return [p for g in groups for p in g.projects if p.name in project_names]

if group_names is not None:
return [p for g in groups if g.name in group_names for p in g.projects]

def filter_projects_on_group_names(groups, names):
"""Filter projects based on given group names
:param list[Group] groups: Groups to filter
:param list[str] names: Group names to match against
:return: List of projects in groups matching given names
:rtype: list[Project]
"""

return [p for g in groups if g.name in names for p in g.projects]
return []


def get_saved_version_names():
Expand Down
9 changes: 2 additions & 7 deletions clowder/clowder/yaml/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from clowder import ROOT_DIR
from clowder.error.clowder_exit import ClowderExit
from clowder.error.clowder_yaml_error import ClowderYAMLError
from clowder.util.clowder_utils import get_clowder_yaml_import_path
from clowder.yaml import __MAX_IMPORT_DEPTH__
from clowder.yaml.parsing import parse_yaml

Expand All @@ -35,13 +36,7 @@ def load_yaml():
break

imported_yaml_files.append(parsed_yaml)
imported_yaml = parsed_yaml['import']

if imported_yaml == 'default':
imported_yaml_file = os.path.join(ROOT_DIR, '.clowder', 'clowder.yaml')
else:
imported_yaml_file = os.path.join(ROOT_DIR, '.clowder', 'versions',
imported_yaml, 'clowder.yaml')
imported_yaml_file = get_clowder_yaml_import_path(parsed_yaml['import'])

parsed_yaml = parse_yaml(imported_yaml_file)
if len(imported_yaml_files) > __MAX_IMPORT_DEPTH__:
Expand Down

0 comments on commit 06a21db

Please sign in to comment.