Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move project to python 3.8 #203

Draft
wants to merge 1 commit into
base: sf_dev_0.3.0_postreg
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run_pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: 'ubuntu-latest'
strategy:
matrix:
python-version: ['3.7']
python-version: ['3.8']

steps:
- name: 'Checkout repo'
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ CellBender can be installed via

$ pip install cellbender

(and we recommend installing in its own ``conda`` environment to prevent
conflicts with other software).
(and we recommend installing in its own ``conda`` environment, using python 3.8,
to prevent conflicts with other software).

CellBender is run as a command-line tool, as in

Expand Down Expand Up @@ -98,7 +98,7 @@ Create a conda environment and activate it:

.. code-block:: console

$ conda create -n cellbender python=3.7
$ conda create -n cellbender python=3.8
$ conda activate cellbender

Install the `pytables <https://www.pytables.org>`_ module:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"check_pytorch_cuda_status.run_check_pytorch_cuda_status.docker_image": "us.gcr.io/broad-dsde-methods/cellbender:20230414"
"check_pytorch_cuda_status.run_check_pytorch_cuda_status.docker_image": "us.gcr.io/broad-dsde-methods/cellbender:20230424"
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ task run_check_pytorch_cuda_status {
import torch
assert torch.cuda.is_available()
CODE

cellbender remove-background -h
}
runtime {
docker: "${docker_image}"
Expand Down
29 changes: 18 additions & 11 deletions cellbender/remove_background/tests/test_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch
from torch.distributions import constraints
import pyro
import pyro.optim as optim
import pyro.optim

import cellbender
from cellbender.remove_background.checkpoint import make_tarball, unpack_tarball, \
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_save_and_load_pyro_checkpoint(tmpdir_factory, batch_size_n):
initial_model = PyroModel(dim=dim)

# set up the inference process
scheduler = optim.ClippedAdam({'lr': lr, 'clip_norm': 10.})
scheduler = pyro.optim.ClippedAdam({'lr': lr, 'clip_norm': 10.})
svi = pyro.infer.SVI(initial_model.model, initial_model.guide, scheduler, loss=pyro.infer.Trace_ELBO())
w1 = _get_params(initial_model.encoder)

Expand Down Expand Up @@ -316,7 +316,7 @@ def test_save_and_load_pyro_checkpoint(tmpdir_factory, batch_size_n):

# one-shot training straight through
model_one_shot = PyroModel(dim=dim) # resets random state
scheduler = optim.ClippedAdam({'lr': lr, 'clip_norm': 10.})
scheduler = pyro.optim.ClippedAdam({'lr': lr, 'clip_norm': 10.})
train_loader = new_train_loader(data=dataset, batch_size=batch_size_n)
svi_one_shot = pyro.infer.SVI(model_one_shot.model, model_one_shot.guide, scheduler, loss=pyro.infer.Trace_ELBO())
model_one_shot.loss.extend(train_pyro(n_epochs=epochs, data_loader=train_loader, svi=svi_one_shot))
Expand Down Expand Up @@ -526,13 +526,20 @@ def test_save_and_load_cellbender_checkpoint(tmpdir_factory, cuda, scheduler):
# 'Guide traces disagree with and without checkpoint restart'


# def ExponentialLR(optim_args) -> pyro.optim.PyroLRScheduler:
# """
# Wraps :class:`pyro.optim.clipped_adam.ClippedAdam` with :class:`~pyro.optim.optim.PyroOptim`.
# """
# return pyro.optim.PyroLRScheduler(torch.optim.lr_scheduler.ExponentialLR, optim_args)


@pytest.mark.parametrize(
"Optim, config",
[
(optim.ClippedAdam, {"lr": 0.01}),
(optim.ExponentialLR, {"optimizer": torch.optim.SGD,
"optim_args": {"lr": 0.01},
"gamma": 0.9}),
(pyro.optim.ClippedAdam, {"lr": 0.01}),
(pyro.optim.ExponentialLR, {"optimizer": torch.optim.SGD,
"optim_args": {"lr": 0.01},
"gamma": 0.9}),
],
)
def test_optimizer_checkpoint_restart(Optim, config, tmpdir_factory):
Expand All @@ -557,7 +564,7 @@ def guide():

def get_snapshot(optimizer):
s = {k: v.data.clone() for k, v in store.items()}
if type(optimizer) == optim.lr_scheduler.PyroLRScheduler:
if type(optimizer) == pyro.optim.lr_scheduler.PyroLRScheduler:
lr = list(optimizer.optim_objs.values())[0].get_last_lr()[0]
else:
lr = list(optimizer.optim_objs.values())[0].param_groups[0]['lr']
Expand All @@ -573,7 +580,7 @@ def get_snapshot(optimizer):
for _ in range(5 + 10):
svi.step()
expected.append(get_snapshot(optimizer))
if type(optimizer) == optim.lr_scheduler.PyroLRScheduler:
if type(optimizer) == pyro.optim.lr_scheduler.PyroLRScheduler:
svi.optim.step()
del svi, optimizer

Expand All @@ -586,7 +593,7 @@ def get_snapshot(optimizer):
for _ in range(5):
svi.step()
actual.append(get_snapshot(optimizer))
if type(optimizer) == optim.lr_scheduler.PyroLRScheduler:
if type(optimizer) == pyro.optim.lr_scheduler.PyroLRScheduler:
svi.optim.step()

# checkpoint
Expand All @@ -605,7 +612,7 @@ def get_snapshot(optimizer):
for _ in range(10):
svi.step()
actual.append(get_snapshot(optimizer))
if type(optimizer) == optim.lr_scheduler.PyroLRScheduler:
if type(optimizer) == pyro.optim.lr_scheduler.PyroLRScheduler:
svi.optim.step()

# display learning rates and actual/expected values for z_loc
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certifi
&& apt-get clean \
&& sudo rm -rf /var/lib/apt/lists/* \
# get miniconda
&& curl -so $HOME/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py37_23.1.0-1-Linux-x86_64.sh \
&& curl -so $HOME/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh \
&& chmod +x $HOME/miniconda.sh \
&& $HOME/miniconda.sh -b -p $CONDA_DIR \
&& rm $HOME/miniconda.sh \
Expand All @@ -30,6 +30,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certifi
# get compiled crcmod for gsutil
&& conda install -y -c conda-forge crcmod \
# install cellbender and its dependencies
&& yes | pip install /software/cellbender/ \
&& yes | pip install -e /software/cellbender/ \
&& conda clean -yaf \
&& sudo rm -rf ~/.cache/pip
2 changes: 1 addition & 1 deletion docker/DockerfileGit
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certifi
&& apt-get clean \
&& sudo rm -rf /var/lib/apt/lists/* \
# get miniconda
&& curl -so $HOME/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py37_23.1.0-1-Linux-x86_64.sh \
&& curl -so $HOME/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh \
&& chmod +x $HOME/miniconda.sh \
&& $HOME/miniconda.sh -b -p $CONDA_DIR \
&& rm $HOME/miniconda.sh \
Expand Down
4 changes: 2 additions & 2 deletions docs/source/installation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ packages you may have installed.

.. code-block:: console

$ conda create -n cellbender python=3.7
$ conda create -n cellbender python=3.8
$ conda activate cellbender
(cellbender) $ pip install cellbender

Expand All @@ -38,7 +38,7 @@ Create a conda environment and activate it:

.. code-block:: console

$ conda create -n cellbender python=3.7
$ conda create -n cellbender python=3.8
$ conda activate cellbender

Install the `pytables <https://www.pytables.org>`_ module:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_version() -> str:
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Scientific/Engineering :: Bio-Informatics',
],
keywords='scRNA-seq bioinformatics',
Expand Down