Skip to content

Commit

Permalink
Fix pylint and pickling issue (#1743)
Browse files Browse the repository at this point in the history
* Fix pylint

* run black

* fix lint

* Change special version

* Add pylint disables

* Add black

* Update pymc3 install branch

* Revert special version

* Change pymc3 master install

* Change to kick off ci

* Use cloudpickle

* Add cloudpickle

* Fix lint

* Remove mypy check for now

* Reenable mypy

* Update not callable line

* Disable mypy until we can find a fix

* Add cloudpickle ignore and renable mypy

* Remove pymc manual install

Co-authored-by: canyon <canyon@canyon.local>
Co-authored-by: canyon289 <ravinsdrive@gmail.com>
  • Loading branch information
3 people authored Jul 26, 2021
1 parent ae83908 commit 86e06d8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
10 changes: 2 additions & 8 deletions .azure-pipelines/azure-pipelines-external.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,8 @@ jobs:
fi
if [ "$(pymc3.version)" = "github" ]; then
# Pip installation is failing for some reason. This is the same thing
git clone https://github.com/pymc-devs/pymc3
cd pymc3
git checkout v4
cd ..
pip install $PWD/pymc3
# python -m pip --no-cache-dir --log log.txt install git+https://github.com/pymc-devs/pymc3
# cat log.txt
python -m pip --no-cache-dir --log log.txt install git+https://github.com/pymc-devs/pymc3
cat log.txt
else
python -m pip --no-cache-dir install pymc3
fi
Expand Down
8 changes: 6 additions & 2 deletions arviz/data/inference_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ def groups(self) -> List[str]:
class InferenceDataValuesView(ValuesView[xr.Dataset]):
"""ValuesView implementation for InferenceData, to allow it to implement Mapping."""

def __init__(self, parent: "InferenceData") -> None:
def __init__(
self, parent: "InferenceData"
) -> None: # pylint: disable=super-init-not-called
"""Create a new InferenceDataValuesView from an InferenceData object."""
self.parent = parent

Expand Down Expand Up @@ -275,7 +277,9 @@ def values(self) -> "InferenceData.InferenceDataValuesView":
class InferenceDataItemsView(ItemsView[str, xr.Dataset]):
"""ItemsView implementation for InferenceData, to allow it to implement Mapping."""

def __init__(self, parent: "InferenceData") -> None:
def __init__(
self, parent: "InferenceData"
) -> None: # pylint: disable=super-init-not-called
"""Create a new InferenceDataItemsView from an InferenceData object."""
self.parent = parent

Expand Down
4 changes: 3 additions & 1 deletion arviz/data/io_pyro.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def arbitrary_element(dct):

observations = {}
if self.model is not None:
trace = pyro.poutine.trace(self.model).get_trace(*self._args, **self._kwargs)
trace = pyro.poutine.trace(self.model).get_trace( # pylint: disable=not-callable
*self._args, **self._kwargs
)
observations = {
name: site["value"].cpu()
for name, site in trace.nodes.items()
Expand Down
8 changes: 4 additions & 4 deletions arviz/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import importlib
import logging
import os
import pickle
import sys
from typing import Any, Dict, List, Optional, Tuple, Union

import cloudpickle
import numpy as np
import pytest
from _pytest.outcomes import Skipped
Expand Down Expand Up @@ -591,13 +591,13 @@ def load_cached_models(eight_schools_data, draws, chains, libs=None):
with gzip.open(path, "wb") as buff:
try:
_log.info("Generating and caching %s", fname)
pickle.dump(func(eight_schools_data, draws, chains), buff)
cloudpickle.dump(func(eight_schools_data, draws, chains), buff)
except AttributeError as err:
raise AttributeError(f"Failed chaching {library_name}") from err
raise AttributeError(f"Failed caching {library_name}") from err

with gzip.open(path, "rb") as buff:
_log.info("Loading %s from cache", fname)
models[library.__name__] = pickle.load(buff)
models[library.__name__] = cloudpickle.load(buff)

return models

Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ ignore_missing_imports = True
[mypy-bokeh.*]
ignore_missing_imports = True

[mypy-cloudpickle.*]
ignore_missing_imports = True

[mypy-cmdstanpy.*]
ignore_missing_imports = True

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pytest-cov
black ; python_version >= '3.6'
typing_copilot ; python_version >= '3.7'
mypy<0.800
cloudpickle

0 comments on commit 86e06d8

Please sign in to comment.