Commands

class workspace.commands.bump.Bump(*args, **kwargs)

Bump dependency versions in requirements.txt, pinned.txt, or any specified file.

Parameters:
  • names (str) – Only bump dependencies that match the name. Name can be a product group name defined in workspace.cfg. To bump to a specific version instead of latest, append version to name (i.e. requests==1.2.3 or ‘requests>=1.2.3’). When > or < is used, be sure to quote.
  • test (int) – Run tests.
  • push (bool) – Push the change. Use with –test to test before pushing.
  • add (bool) – Add the names to the requirements file if they don’t exist.
  • msg (str) – Summary commit message
  • file (str/list) – Requirement file to bump. Defaults to requirements.txt or pinned.txt that are set by bump.requirement_files in workspace.cfg.
  • bumper_models (dict) – List of classes that implements bumper.cars.AbstractBumper Defaults to bumper.cars.RequirementsBumper
  • force (bool) – Force a bump even when certain bump requirements are not met.
  • dry_run (bool) – Perform a dry run by printing out the changes only without making changes.
  • kwargs (dict) – Additional args from argparse
run()
Returns:Tuple with 3 elements: A map of file to bump message, commit message, and list of Bump
class workspace.commands.checkout.Checkout(**kwargs)

Checkout products (repo urls) or branch, or revert files.

Parameters:target (list) – List of products (git repository URLs) to checkout. When inside a git repo, checkout the branch or revert changes for file(s).
class workspace.commands.clean.Clean(**kwargs)

Clean workspace by removing build, dist, and .pyc files

class workspace.commands.commit.Commit(**kwargs)

Commit all changes locally, including new files.

Parameters:
  • msg (str) – Commit message. The first few words are used to create the branch name if branch isn’t provided. That behavior can be configured with [commit] auto_branch_from_commit_words
  • branch (str) – Use specified branch for commit instead of auto-computing the branch from commit msg.
  • amend (bool) – Amend last commit with any new changes made
  • test (bool) – Run tests. Repeat twice (-tt) to test dependents too.
  • push (bool|int) – Push the current branch after commit. Repeat twice (-pp) to push to all remotes.
  • discard (int) – Discard last commit, or branch (child only) if there are no more commits. Use multiple times to discard multiple commits. Other options are ignored. Any local changes may be discarded (hard reset)
  • move (str) – Move last commit to branch. Other options are ignored.
  • test_command (callable) – Alternative test command to run
  • skip_auto_branch (bool) – Skip automatic branch creation from commit msg
  • files (list) – List of files to add instead of all files.
class workspace.commands.diff.Diff(**kwargs)

Show diff on current product or all products in workspace

Parameters:
  • context (str) – Show diff for context (i.e. branch or file)
  • parent (bool) – Diff against the parent branch. If there is not parent, defaults to master.
  • name_only (bool) – List file names only. Git only.
class workspace.commands.log.Log(**kwargs)

Show commit logs.

Extra arguments are passed to the underlying SCM’s log command.

Parameters:
  • diff (bool) – Generate patch / show diff
  • show (str) – Show specific revision. This implies –diff and limit of 1
  • limit (int) – Limit number of log entries
  • extra_args (list) – Extra args to pass to the underlying SCM’s log command
class workspace.commands.publish.Publish(**kwargs)

Bumps version in setup.py (defaults to patch), writes out changelog, builds a source distribution, and uploads with twine.

Parameters:
  • repo (str) – Repository to publish to
  • minor (bool) – Perform a minor publish by bumping the minor version
  • major (bool) – Perform a major publish by bumping the major version
bump_version()

Bump the version (defaults to patch) in setup.py

update_changelog(new_version, changes, skip_title_change=False)
Parameters:
  • new_version (str) – New version
  • changes (list[str]) – List of changes
  • skip_title_change (bool) – Skip title change
Returns:

Path to changelog file

class workspace.commands.push.Push(**kwargs)

Push changes for branch

Parameters:
  • branch (str) – The branch to push. Defaults to current branch.
  • all_remotes (bool) – Push changes to all remotes
  • merge (bool) – Merge the branch into its parent branch before push
  • force (bool) – Force the push
class workspace.commands.setup.Setup(**kwargs)

Sets up workspace or product environment.

Parameters:
  • product_group (str) – Setup product group by checking them out, developing them, and running any setup scripts and exports as defined by setup.cfg in each product.
  • product (bool) – Initialize product by setting up tox with py27, style, and coverage test environments. Also create setup.py, README.rst, and test directories if they don’t exist.
  • commands (bool) – Add convenience bash function for certain commands, such as checkout to run “workspace checkout”, or “ws” bash function that goes to your workspace directory when no argument is passed in, otherwise runs wst command.
  • commands_with_aliases (bool) – Same as –commands plus add shortcut aliases, like “co” for checkout. This is for those developers that want to get as much done with the least key strokes - true efficienist! ;)
  • uninstall (bool) – Uninstall all functions/aliases.
additional_commands = None

Dict for additional commands to setup

class workspace.commands.status.Status(**kwargs)

Show status on current product or all products in workspace

class workspace.commands.test.Test(*args, **kwargs)

Run tests and manage test environments for product.

Extra optional boolean args (such as -s, -v, -vv, etc) are passed to py.test.

Parameters:
  • env_or_file (list) – The tox environment to act upon, or a file to pass to py.test (only used if file exists, we don’t need to redevelop, and py.test is used as a command for the default environements). Defaults to the envlist in tox.
  • repo (str) – Repo path to test instead of current repo
  • show_dependencies (bool) – Show where product dependencies are installed from and their versions.
  • test_dependents (bool) – Run tests in this product and in checked out products that depends on this product. This product must be installed as editable in its dependents for the results to be useful. Most args are ignored when this is used.
  • redevelop (bool) – Redevelop the test environment by installing on top of existing one. This is implied if test environment does not exist, or whenever requirements.txt or pinned.txt is modified after the environment was last updated. Use -ro to do redevelop only without running tests. Use -rr to remove the test environment first before redevelop (recreate).
  • install_only (bool) – Modifier for redevelop. Perform install only without running test.
  • match_test (bool) – Only run tests with method name that matches pattern
  • return_output (bool) – Return test output instead of printing to stdout
  • num_processes (str) – Number of processes to use when running tests in parallel
  • tox_cmd (list) – Alternative tox command to run. If env is passed in (from env_or_file), ‘-e env’ will be appended as well.
  • tox_ini (str) – Path to tox_ini file.
  • tox_commands (dict) – Map of env to list of commands to override “[testenv:env] commands” setting for env. Only used when not developing.
  • args (list) – Additional args to pass to py.test
  • silent (bool) – Run tox/py.test silently. Only errors are printed and followed by exit.
  • debug (bool) – Turn on debug logging
  • install_editable (list) – List of products or product groups to install in editable mode.
  • extra_args (list) – Extra args from argparse to be passed to py.test
Returns:

Dict of env to commands ran on success. If return_output is True, return a string output. If test_dependents is True, return a mapping of product name to the mentioned results.

classmethod summarize(tests, include_no_tests=True)

Summarize the test results

Parameters:
  • tests (dict|str) – Map of product name to test result, or the test result of the current prod.
  • include_no_tests (bool) – Include “No tests” results when there are no tests found.
Returns:

A tuple of (success, list(summaries)) where success is True if all tests pass and summaries is a list of passed/failed summary of each test or just str if ‘tests’ param is str.

class workspace.commands.update.Update(*args, **kwargs)

Update current product or all products in workspace

Parameters:products (list) – When updating all products, filter by these products or product groups