Copyright (C) 2018 Simon Kallfass
conda-commands used by the pproject-module.
ouroboros.tools.pproject.conda.
CondaEnvironment
(name)[source]¶Bases: object
Class representing a conda-environment. Includes methods for creation, removal (local and remote) of the conda-environment.
create
(dependencies)[source]¶Create conda-environment with name self.name and passed dependencies.
Parameters: | dependencies (list) – List of strings with dependencies (packagename with optional version) to install inside environment.
|
---|
create_remote
(ssh, pythonversion, packagename, version, projectpath)[source]¶Release the package in its own conda-envrionment on a remote host.
Parameters: |
|
---|
exists
()[source]¶Check if conda-environment with name self.name exists.
Returns: | bool – True if conda-environment exists, else False. |
---|
recreate
(dependencies)[source]¶Remove conda-environment if it already exists. Then creates new environment as self.name with passed dependencies.
Parameters: | dependencies (list) – List of strings with dependencies (packagename with optional version) to install inside environment.
|
---|
release_log
(ssh, action, projectpath)[source]¶Write information about ssh-interaction on the destination host as passed in ssh.
action as a string to log into the log-file.
ouroboros.tools.pproject.conda.
MetaYaml
(path=None)[source]¶Bases: object
Class representing the meta.yaml file of a python-conda-package. Includes a get_content-method for reading the content of the meta.yaml-file and a update-method which calls the get_content-method and updates the class-attributes with the collected informations.
path
¶str
content
¶dict
dependencies
¶dict
pythonversion
¶str
package_name
¶str
get_content
()[source]¶Collects the contents of the meta.yaml file and returns the collected informations.
Returns: | content (dict) – Contents of the meta.yaml file. |
---|
update
()[source]¶Updates the class-attributes with informations collected by the get_content-method.
Note
Uses method MetaYaml.get_content()
to collect the content of the
meta.yaml file.
ouroboros.tools.pproject.conda.
build_package
(path, pythonversion, simulate=False)[source]¶Build conda-package from source at passed path for passed pythonversion. If simulate is set to True, the package isn’t built. The function only returns the path of the resulting package if it would have been built.
Parameters: |
|
---|---|
Returns: | result (str) – The path of the resulting conda-package (simulated or real). |
Copyright (C) 2018 Simon Kallfass
git- and gitlab-commands used by the pproject-module.
ouroboros.tools.pproject.git.
GitRepo
(path)[source]¶Bases: object
Class representing a local git-repository. Includes methods to check its status, initialize, add, push, create tag, etc.
check_tag_on_remote
()[source]¶Check if current tag is pushed to the origin url.
Returns: | check (bool) |
---|
create_tag
(tag, message)[source]¶Create git tag as passed with passed message for current local git-repository.
Parameters: |
|
---|
get_email
()[source]¶Collect the email of the current user as defined in the .gitconfig-file.
Returns: | str – Email of current user as defined in the .gitconfig-file. |
---|
get_tag
()[source]¶Try to get the git tag for the current local git-repository and returns the result. If the repo doesn’t have a git tag yet, it returns “0.0.0”
Returns: | str – Git tag for current local git-repository or “0.0.0” if no git tag available yet. |
---|
get_username
()[source]¶Collect the name of the current user as defined in the .gitconfig-file.
Returns: | str – Name of current user as defined in the .gitconfig-file. |
---|
push_tag
(tag)[source]¶Push passed tag of current local git-repository to its origin.
Parameters: | tag (str) – The tag to push to the git-repositories origin. |
---|
push_to_branch
(branch)[source]¶Push passed branch of current local git-repository to its origin.
Parameters: | branch (str) – Branchname to push to origin. |
---|
ouroboros.tools.pproject.git.
check_remote_vcs
()[source]¶Check if the vcs-url is reachable.
Returns: | check_result (bool) – Result for the remote vcs to check. |
---|
ouroboros.tools.pproject.git.
create_on_remote_vcs
(*, company, namespace, project, username)[source]¶Create new project on remote vcs (as defined in config) based on the passed values “company”, “namespace” and “project”.
Parameters: |
|
---|---|
Returns: | project_to_create/gitlab_group (str) – The name of the created project / The name of the gitlab-group in which the project was created. |
Copyright (C) 2018 Simon Kallfass
Provides the functions used for visual output for the user inside the pproject-tool.
ouroboros.tools.pproject.inform.
BOLD
= '\x1b[1;37m'¶str – Bold-style used for visual output for the user.
ouroboros.tools.pproject.inform.
CYAN
= '\x1b[0;94m'¶str – Color cyan used for visual output for the user.
ouroboros.tools.pproject.inform.
GREEN
= '\x1b[1;92m'¶str – Color green used for visual output for the user.
ouroboros.tools.pproject.inform.
NCOLOR
= '\x1b[0m'¶str – Resets the color used for visual output for the user.
ouroboros.tools.pproject.inform.
RED
= '\x1b[1;91m'¶str – Color red used for visual output for the user.
ouroboros.tools.pproject.inform.
critical
(msg=None)[source]¶Generates output in defined critical-style for the user. Stops the pproject-script with sys.exit(1).
Parameters: | msg (str) – (default=None) Message to output for the user in info-style. Before existing. |
---|
ouroboros.tools.pproject.inform.
error
(msg=None)[source]¶Generates output in defined error-style for the user.
Parameters: | msg (str) – (default=None) Message to output for the user in info-style. |
---|
Copyright (C) 2018 Simon Kallfass
The pproject-module provides the functionality and logic used by the pproject.sh-file.
ouroboros.tools.pproject.pproject.
Project
(company, namespace, project, pythonversion, path=PosixPath('/home/ektom/devl/ouroboros-tools-pproject'))[source]¶Bases: object
Class representing an pproject-project. It contains methods to create new projects with cookiecutter, update project-environment, test defined tests with pytest, build a conda-package from the project, increase projects git-tag based on semantic versioning, release of the project as a conda-package in its on environment on another host.
company
¶str – The name of the company to use in the project.
namespace
¶str – The namespace in which the project is placed.
project
¶str – The name of the project.
pythonversion
¶str – The pythonversion to use inside the project.
username
¶str – The name of the author of the project (collected by git config).
email
¶str – The email of the author of the project (collected by git config).
year
¶str – The year in which the project was created.
today
¶str – The date when the project was created.
version
¶str – The current git tag of the project. Collected by git describe tag. Should be raised with “pproject new_version”.
environment
¶str – The name of the conda-environment associated with the project. Either collected from meta.yaml if project already exists, or combined by “company-namespace-project” if created.
git
¶git.GitRepo – Enables git-interactions for project.
build
(publish=False, path=None)[source]¶Builds a conda-package from the project. First it runs all tests to ensure functionality of the resulting package. Assuming the test-coverage is acceptable. Then it checks for uncommited stuff inside the project and if it is tagged with a version-tag. Finally the conda-package is build. If the publish-flag is set it is uploaded to the conda-repo-server. Else it is only built local.
Parameters: |
|
---|
Note
Runs Project.test()
before build to check for failures.
Checks if uncommited stuff remains inside project-folder before build
with check_git_status()
.
Also checks if a required git-tag exists with get_git_tag()
.
To execute the conda-build command utils.run_in_bash()
is used.
create
(on_vcs=False, path=None)[source]¶Creates new project based on a defined skeleton either local or on gitlab with cookiecutter, creates the base-conda-environment for developing the new project and manages corresponding git-tasks.
Parameters: |
|
---|
Note
Calls Project.update_informations()
with create=True to
update the attributes of the project.
For git operations the function utils.run_in_bash()
is called.
After creation Project.update()
with path set to current
working directory is called to create the conda-environment of the
project.
info
(path=None)[source]¶Collects and prints information about the pproject-configuration and the current project.
Parameters: | path (pathlib.Path) – The projects path. |
---|
Note
Uses conda.MetaYaml
to collect the project informations.
The current version is collected by get_git_tag()
.
Resulting packagename is collected by
conda.build_package()
.
The pproject-settings are collected by the global variables.
new_version
(vtype, message='New version triggered by pproject', path=None)[source]¶Raises the passed vtype (versiontype) inside version (git-tag) of the project. Version has to be in semantic versioning style (see https://semver.org/ for details). Example for version in semantic versioning style: General: “major.minor.patch” Example: “1.0.1”
Parameters: |
|
---|
Note
First checks if there is uncommited stuff inside the current branch.
If there is uncommited stuff, the operation is aborted.
Else checks if the gitlab is reachable.
Then the current version is collected.
The passed vtype is raised by 1. Finally the resulting version-tag
is added with passed message and the new tag is pushed to gitlab.
For these operations git.GitRepo
is used.
release
(dst='localhost', envname=None, path=None)[source]¶Rolls out the current project as a conda-package in its own conda-environment either on localhost or on a remote.
Parameters: |
|
---|
Note
The version of the project is collected by get_git_tag()
.
Then the project is build as a conda-package with
Project.build()
. If destination is “localhost”, the creation
of the conda-envrionment for the just created package is done by
utils.run_in_bash()
. Else the required commands are executed by
paramiko.
sphinx
(path=None)[source]¶Creates a sphinx documentation for the current pproject project.
Parameters: | path (pathlib.Path) – The projects path. |
---|
test
(path=None)[source]¶Runs all tests for the project in its tests folder with pytest.
Parameters: | path (pathlib.Path) – The projects path. |
---|
Note
Calls Project.test()
to update the projects conda-environment
before running the tests with pytest.
update
(path=None)[source]¶Updates the project-related conda-environment. If it already exists it will be removed and then recreated. This ensures to remove dependencies of packages which aren’t required anymore. If the environment doesn’t exist yet, the environment will be created. Finally stores the md5sum of the based meta.yaml file inside a file to enable the pproject-autoenv functionality triggered by changes inside the meta.yaml file.
Parameters: | path (str) – Path of the required meta.yaml file. Only required if the meta.yaml is outside of the current working directory |
---|
Note
The pythonversion and the dependencies are collected with
conda.MetaYaml
. Environment creation/removal is done using
conda.CondaEnvironment
.
To calculate the new md5sum of the meta.yaml and store it inside the
hash.md5-file, update_md5sum()
is used.
update_informations
(create=False, path=None)[source]¶Updates class-attributes with new informations collected from meta.yaml, git config and current datetime.
Parameters: |
|
---|
Note
Uses conda.MetaYaml
to collect the name of environment
from the current project if create is False.
To collect git-specific informations git.GitRepo
is used.
Checks for valid project-definition with validators.SProject
.
ouroboros.tools.pproject.pproject.
build_arguments
(args)[source]¶The argument parsing for the python-part of the pproject-tool.
Parameters: | args (list) |
---|---|
Returns: | parsed_args (argparse.Namespace) |
ouroboros.tools.pproject.pproject.
general_info
()[source]¶Collects and prints information about the pproject-configuration and the current project.
Note
The pproject-settings are collected by the global variables.
ouroboros.tools.pproject.pproject.
main
()[source]¶The main function coordinating the python-part of the pproject-tool.
Note
The arguments are parsed by build_arguments()
.
All other operations are done by conda.MetaYaml
and
Project
and their methods.
Copyright (C) 2018 Simon Kallfass
sphinx-commands used by the pproject-module.
ouroboros.tools.pproject.sphinx.
COMPANY
= 'ouroboros'¶str – The company name to use for new project creations based on “pproject create”.
ouroboros.tools.pproject.sphinx.
PPROJECT_ENV_PATH
= '/var/local/conda/envs/pproject'¶str – The folder where the pproject-env is stored.
ouroboros.tools.pproject.sphinx.
create_coverage_badge
(path, environment)[source]¶Run pytest-cov and create coverage-badge for the coverage-result. Store the resulting badge inside the static folder for use inside documentation.
Parameters: |
|
---|
ouroboros.tools.pproject.sphinx.
customize_config
(path)[source]¶Rename content of source/conf.py for custom setup.
Parameters: | path (pathlib.Path) – Path to create the documentation for. |
---|
ouroboros.tools.pproject.sphinx.
make_documentation
(path)[source]¶Generatie html- and pdf-documentation for passed path.
Parameters: | path (pathlib.Path) – Path to create the documentation for. |
---|
ouroboros.tools.pproject.sphinx.
run_sphinx_quickstart
(path, environment, username, version)[source]¶Run sphinx-quickstart for the passed path. Required variables for this setup are the passed environment (as name of the project), the username and the version of the project to document.
Parameters: |
|
---|
Copyright (C) 2018 Simon Kallfass
Utils used by the pproject-module like md5sum-calculations, config-loading, executing commands in bash and ssh-interactions.
ouroboros.tools.pproject.utils.
connect_ssh
(dst)[source]¶Connect to destination host (dst).
Parameters: | dst (str) – The destination-host as combination of “username@hostname”. |
---|---|
Returns: | paramiko.SSHClient – The connection-object to the dst-host. |
ouroboros.tools.pproject.utils.
get_config_for_terminal
()[source]¶Reads the config file of pproject and prints the content. Used to source the config variables inside the pproject.sh script.
Parameters: | path (pathlib.Path) – The path of the config file. |
---|
ouroboros.tools.pproject.utils.
load_configs
(default_config_path=None, user_config_path=None)[source]¶Unwritten yet
Parameters: |
|
---|---|
Returns: | list – List of dicts containing “default_config”-content and “user_config”-content. |
Copyright (C) 2018 Simon Kallfass
Provides validators used in the pproject-module (project-, config- and meta.yaml-validations).
ouroboros.tools.pproject.validators.
SBuild
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class for the build-section used as nested-field in SMetaYaml.
build
¶str
preserve_egg_dir
¶bool
entry_points
¶list
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
SConfig
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class for the pproject-config.
conda_folder
¶str
meta_yaml_path
¶str
meta_yaml_md5_path
¶str
environment_yaml_path
¶str
pproject_env
¶str
skeleton_repo
¶str
company
¶str
gitlab_url
¶str
gitlab_api
¶str
gitlab_token_path
¶str
gitlab_ssh
¶str
conda_repo_userathost
¶str
conda_repo_pkgs_path
¶str
conda_repo_conda_bin
¶str
pytest_arguments
¶list
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
SExtra
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class for the extra-section used as nested-field in SMetaYaml.
maintainer
¶str
pythonversion
¶str
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
SMetaYaml
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class to use for meta.yaml-contents used in pproject.
package
¶marshmallow.fields.Nested
source
¶marshmallow.fields.Nested
build
¶marshmallow.fields.Nested
requirements
¶marshmallow.fields.Nested
test
¶marshmallow.fields.Nested
about
¶dict
extra
¶marshmallow.fields.Nested
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
SPackage
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class for the package-section used as nested-field in SMetaYaml.
name
¶str
version
¶str
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
SProject
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class for pproject-projects.
company
¶str
namespace
¶str
project
¶str
pythonversion
¶str
username
¶str
email
¶str
year
¶str
today
¶str
version
¶str
environment
¶str
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
SRequirements
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class for the requirements-section used as nested-field in SMetaYaml.
build
¶list
run
¶list
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
SSource
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class for the source-section used as nested-field in SMetaYaml.
path
¶str
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
STest
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: ouroboros.tools.pproject.validators.SToasted
The schema-class for the test-section used as nested-field in SMetaYaml.
imports
¶list
commands
¶list
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
SToasted
(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]¶Bases: marshmallow.schema.Schema
The base-Schema-class to use for all other schemata in this module. Using toastedmarshmallow.Jit speeds up validation.
Meta
[source]¶Bases: object
Meta-class used to speed up marshmallow-validation.
jit
¶alias of toastedmarshmallow.Jit
opts
= <marshmallow.schema.SchemaOpts object>¶ouroboros.tools.pproject.validators.
validate_environmentname
(environment)[source]¶Validates if the passed environment is valid.
Parameters: | environment (str) – The environment-name to validate. |
---|---|
Raises: | marshmallow.ValidationError – If environment isn’t valid, raises a marshmallow.ValidationError. |
ouroboros.tools.pproject.validators.
validate_path_exists
(path)[source]¶Validates if the passed path exists.
Parameters: | path (str) – The path to check. |
---|---|
Raises: | marshmallow.ValidationError – If path doesn’t exist, raises a marshmallow.ValidationError. |
ouroboros.tools.pproject.validators.
validate_url
(url)[source]¶Validates if the passed url is valid.
Parameters: | url (str) – The url to validate. |
---|---|
Raises: | marshmallow.ValidationError – If passed url isn’t valid, raises a marshmallow.ValidationError. |
ouroboros.tools.pproject.validators.
validate_version
(version)[source]¶Validates if the passed version is valid (form and semantic-versioning-style).
Parameters: | version (str) – The version to validate. |
---|---|
Raises: | marshmallow.ValidationError – If version isn’t valid, raises a marshmallow.ValidationError. |
© Copyright 2018, Simon Kallfass.
ImpressumThis site was generated using Sphinx and the Sphinx-Bootstrap-Theme