forked from bel-curation/pybel-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
260 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,107 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# IDEA | ||
.idea |
This file contains 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,3 @@ | ||
pybel-git | ||
========= | ||
Git and continuous integration tools for PyBEL. |
This file contains 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,49 @@ | ||
########################## | ||
# Setup.py Configuration # | ||
########################## | ||
# Configuring setup() | ||
[metadata] | ||
name = pybel_git | ||
version = 0.0.1-dev | ||
author = Charles Tapley Hoyt | ||
author_email = [email protected] | ||
maintainer = Charles Tapley Hoyt | ||
maintainer_email = [email protected] | ||
classifiers = | ||
Development Status :: 1 - Planning | ||
Intended Audience :: Developers | ||
Programming Language :: Python | ||
Programming Language :: Python :: 3.7 | ||
Programming Language :: Python :: 3.6 | ||
Programming Language :: Python :: 3 :: Only | ||
License :: OSI Approved :: MIT License | ||
license = MIT | ||
license_file = LICENSE | ||
description = PyBEL Git utilities | ||
long_description = file: README.rst | ||
keywords = | ||
Biological Expression Language | ||
Protein Protein Interaction Networks | ||
|
||
[options] | ||
install_requires = | ||
pybel | ||
click | ||
easy-config | ||
gitpython | ||
python_requires = >=3.6 | ||
packages = find: | ||
package_dir = | ||
= src | ||
zip-safe = false | ||
|
||
[options.entry_points] | ||
console_scripts = | ||
pybel-git = pybel_git.cli:main | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
# configuring bdist_wheel | ||
[bdist_wheel] | ||
python-tag = py36 |
This file contains 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,8 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Setup module for PyBEL-Git.""" | ||
|
||
import setuptools | ||
|
||
if __name__ == '__main__': | ||
setuptools.setup() |
This file contains 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 @@ | ||
# -*- coding: utf-8 -*- |
This file contains 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,6 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .cli import main | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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,49 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Command line interface for PyBEL-Git.""" | ||
|
||
import os | ||
import sys | ||
|
||
import click | ||
from git import Repo | ||
|
||
from pybel import Manager, from_path | ||
from pybel.cli import connection_option | ||
from .commands import get_changed | ||
|
||
EMOJI = '🔔' | ||
|
||
|
||
@click.group() | ||
def main(): | ||
"""PyBEL Git utilities.""" | ||
|
||
|
||
# TODO download pre-built cache? | ||
|
||
@main.command() | ||
@click.option('-d', '--directory', default=os.getcwd(), type=click.Path(file_okay=False, dir_okay=True), | ||
help='Directory of git repository') | ||
@connection_option | ||
def ci(directory: str, connection: str): | ||
"""Run in continuous integration setting.""" | ||
click.echo(f'{EMOJI} checking directory: {directory}') | ||
|
||
repo = Repo(directory) | ||
head_commit = repo.git.rev_parse('HEAD') | ||
click.echo(f'{EMOJI} head commit: {head_commit}') | ||
|
||
file_names = get_changed(repo) | ||
if not file_names: | ||
sys.exit(0) | ||
|
||
manager = Manager(connection=connection) | ||
failures = [] | ||
for file_name in file_names: | ||
click.echo(f'{EMOJI} file changed: {file_name}') | ||
graph = from_path(file_name, manager=manager) | ||
if graph.warnings: | ||
failures.append(graph) | ||
|
||
sys.exit(1 if failures else 0) |
This file contains 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,18 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
from typing import List | ||
|
||
from git import Repo | ||
|
||
|
||
def get_changed(repo: Repo) -> List[str]: | ||
"""Get a list of files that have changed in the last commit.""" | ||
head_commit = repo.git.rev_parse('HEAD') | ||
output = repo.git.diff_tree('--no-commit-id', '--name-only', '-r', head_commit) | ||
|
||
return [ | ||
name | ||
for name in output.split('\n') | ||
if name.endswith('.bel') | ||
] |
This file contains 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,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Configuration for PyBEL-Git.""" | ||
|
||
import logging | ||
|
||
from easy_config import EasyConfig | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class PyBELGitConfig(EasyConfig): | ||
"""Configuration for PyBEL-Git.""" | ||
NAME = 'pybel_git' | ||
FILES = [] | ||
|
||
|
||
pybel_git_config = PyBELGitConfig.load() | ||
log.info('loaded pybel-git configuration: %s', pybel_git_config) |