Skip to content

Commit

Permalink
Ci updates (#7)
Browse files Browse the repository at this point in the history
* updated Github Actions and Codecov badges in README.md

* used black to reformat all files outside of src folder

* added Codecov report upload to CI.yaml
  • Loading branch information
jessicaw9910 authored Feb 21, 2024
1 parent 0369768 commit 695b5fb
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 57 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ jobs:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
env:
token: ${{ secrets.CODECOV_TOKEN }}
slug: choderalab/missense-kinase-toolkit
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
missense-kinase-toolkit
==============================
[//]: # (Badges)
[![GitHub Actions Build Status](https://github.com/REPLACE_WITH_OWNER_ACCOUNT/missense_kinase_toolkit/workflows/CI/badge.svg)](https://github.com/REPLACE_WITH_OWNER_ACCOUNT/missense_kinase_toolkit/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/REPLACE_WITH_OWNER_ACCOUNT/missense-kinase-toolkit/branch/main/graph/badge.svg)](https://codecov.io/gh/REPLACE_WITH_OWNER_ACCOUNT/missense-kinase-toolkit/branch/main)
[![GitHub Actions Build Status](https://github.com/choderalab/missense_kinase_toolkit/workflows/CI/badge.svg)](https://github.com/choderalab/missense_kinase_toolkit/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/choderalab/missense-kinase-toolkit/branch/main/graph/badge.svg)](https://codecov.io/gh/choderalab/missense-kinase-toolkit/branch/main)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/choderalab/missense-kinase-toolkit/main.svg?badge_token=dufHMzu_RH2VGGToCgvtcQ)](https://results.pre-commit.ci/latest/github/choderalab/missense-kinase-toolkit/main?badge_token=dufHMzu_RH2VGGToCgvtcQ)


Expand Down
66 changes: 43 additions & 23 deletions devtools/scripts/create_conda_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import subprocess as sp
from tempfile import TemporaryDirectory
from contextlib import contextmanager

# YAML imports
try:
import yaml # PyYAML

loader = yaml.safe_load
except ImportError:
try:
Expand All @@ -17,19 +19,30 @@
try:
# Load Ruamel YAML from the base conda environment
from importlib import util as import_util
CONDA_BIN = os.path.dirname(os.environ['CONDA_EXE'])
ruamel_yaml_path = glob.glob(os.path.join(CONDA_BIN, '..',
'lib', 'python*.*', 'site-packages',
'ruamel_yaml', '__init__.py'))[0]

CONDA_BIN = os.path.dirname(os.environ["CONDA_EXE"])
ruamel_yaml_path = glob.glob(
os.path.join(
CONDA_BIN,
"..",
"lib",
"python*.*",
"site-packages",
"ruamel_yaml",
"__init__.py",
)
)[0]
# Based on importlib example, but only needs to load_module since its the whole package, not just
# a module
spec = import_util.spec_from_file_location('ruamel_yaml', ruamel_yaml_path)
spec = import_util.spec_from_file_location("ruamel_yaml", ruamel_yaml_path)
yaml = spec.loader.load_module()
except (KeyError, ImportError, IndexError):
raise ImportError("No YAML parser could be found in this or the conda environment. "
"Could not find PyYAML or Ruamel YAML in the current environment, "
"AND could not find Ruamel YAML in the base conda environment through CONDA_EXE path. "
"Environment not created!")
raise ImportError(
"No YAML parser could be found in this or the conda environment. "
"Could not find PyYAML or Ruamel YAML in the current environment, "
"AND could not find Ruamel YAML in the base conda environment through CONDA_EXE path. "
"Environment not created!"
)
loader = yaml.YAML(typ="safe").load # typ="safe" avoids odd typing on output


Expand All @@ -46,13 +59,16 @@ def temp_cd():


# Args
parser = argparse.ArgumentParser(description='Creates a conda environment from file for a given Python version.')
parser.add_argument('-n', '--name', type=str,
help='The name of the created Python environment')
parser.add_argument('-p', '--python', type=str,
help='The version of the created Python environment')
parser.add_argument('conda_file',
help='The file for the created Python environment')
parser = argparse.ArgumentParser(
description="Creates a conda environment from file for a given Python version."
)
parser.add_argument(
"-n", "--name", type=str, help="The name of the created Python environment"
)
parser.add_argument(
"-p", "--python", type=str, help="The version of the created Python environment"
)
parser.add_argument("conda_file", help="The file for the created Python environment")

args = parser.parse_args()

Expand All @@ -63,24 +79,28 @@ def temp_cd():
python_replacement_string = f"python {args.python}*"

try:
for dep_index, dep_value in enumerate(yaml_script['dependencies']):
if re.match('python([ ><=*]+[0-9.*]*)?$', dep_value): # Match explicitly 'python' and its formats
yaml_script['dependencies'].pop(dep_index)
for dep_index, dep_value in enumerate(yaml_script["dependencies"]):
if re.match(
"python([ ><=*]+[0-9.*]*)?$", dep_value
): # Match explicitly 'python' and its formats
yaml_script["dependencies"].pop(dep_index)
break # Making the assumption there is only one Python entry, also avoids need to enumerate in reverse
except (KeyError, TypeError):
# Case of no dependencies key, or dependencies: None
yaml_script['dependencies'] = []
yaml_script["dependencies"] = []
finally:
# Ensure the python version is added in. Even if the code does not need it, we assume the env does
yaml_script['dependencies'].insert(0, python_replacement_string)
yaml_script["dependencies"].insert(0, python_replacement_string)

# Figure out conda path
if "CONDA_EXE" in os.environ:
conda_path = os.environ["CONDA_EXE"]
else:
conda_path = shutil.which("conda")
if conda_path is None:
raise RuntimeError("Could not find a conda binary in CONDA_EXE variable or in executable search path")
raise RuntimeError(
"Could not find a conda binary in CONDA_EXE variable or in executable search path"
)

print(f"CONDA ENV NAME {args.name}")
print(f"PYTHON VERSION {args.python}")
Expand All @@ -90,6 +110,6 @@ def temp_cd():
# Write to a temp directory which will always be cleaned up
with temp_cd():
temp_file_name = "temp_script.yaml"
with open(temp_file_name, 'w') as f:
with open(temp_file_name, "w") as f:
f.write(yaml.dump(yaml_script))
sp.call(f"{conda_path} env create -n {args.name} -f {temp_file_name}", shell=True)
80 changes: 48 additions & 32 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@
# Incase the project was not installed
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

import missense_kinase_toolkit


# -- Project information -----------------------------------------------------

project = 'missense-kinase-toolkit'
copyright = ("2024, Jess White. Project structure based on the "
"Computational Molecular Science Python Cookiecutter version 1.1")
author = 'Jess White'
project = "missense-kinase-toolkit"
copyright = (
"2024, Jess White. Project structure based on the "
"Computational Molecular Science Python Cookiecutter version 1.1"
)
author = "Jess White"

# The short X.Y version
version = ''
version = ""
# The full version, including alpha/beta/rc tags
release = ''
release = ""


# -- General configuration ---------------------------------------------------
Expand All @@ -42,13 +45,13 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinx.ext.intersphinx',
'sphinx.ext.extlinks',
"sphinx.ext.autosummary",
"sphinx.ext.autodoc",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.extlinks",
]

autosummary_generate = True
Expand All @@ -57,16 +60,16 @@
napoleon_use_ivar = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -78,18 +81,18 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'default'
pygments_style = "default"


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -100,7 +103,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand All @@ -116,7 +119,7 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'missense_kinase_toolkitdoc'
htmlhelp_basename = "missense_kinase_toolkitdoc"


# -- Options for LaTeX output ------------------------------------------------
Expand All @@ -125,15 +128,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -143,8 +143,13 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'missense_kinase_toolkit.tex', 'missense-kinase-toolkit Documentation',
'missense_kinase_toolkit', 'manual'),
(
master_doc,
"missense_kinase_toolkit.tex",
"missense-kinase-toolkit Documentation",
"missense_kinase_toolkit",
"manual",
),
]


Expand All @@ -153,8 +158,13 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'missense_kinase_toolkit', 'missense-kinase-toolkit Documentation',
[author], 1)
(
master_doc,
"missense_kinase_toolkit",
"missense-kinase-toolkit Documentation",
[author],
1,
)
]


Expand All @@ -164,9 +174,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'missense_kinase_toolkit', 'missense-kinase-toolkit Documentation',
author, 'missense_kinase_toolkit', 'An ETL pipeline package to facilitate structure-based ML for human kinase property prediction',
'Miscellaneous'),
(
master_doc,
"missense_kinase_toolkit",
"missense-kinase-toolkit Documentation",
author,
"missense_kinase_toolkit",
"An ETL pipeline package to facilitate structure-based ML for human kinase property prediction",
"Miscellaneous",
),
]


Expand Down

0 comments on commit 695b5fb

Please sign in to comment.