BasisResearch / cities

Home of Basis development for the 2023 TOP Sprint
MIT License
6 stars 0 forks source link

Pyro version 1.9.1 causes tests to fail #122

Open ellieyhcheng opened 1 month ago

ellieyhcheng commented 1 month ago

Pyro version 1.9.1 causes tests in tests/test_inference.py to fail when loading guides.

======================================================================== FAILURES =========================================================================
_____________________________________ test_smoke_CausalInsigth[1-industry_real_estate_total-spending_transportation] ______________________________________

intervention = 'spending_transportation', outcome = 'industry_real_estate_total', shift = 1

    @pytest.mark.parametrize("intervention", interventions)
    @pytest.mark.parametrize("outcome", outcomes)
    @pytest.mark.parametrize("shift", shifts)
    def test_smoke_CausalInsigth(intervention, outcome, shift):
        ci = CausalInsight(
            outcome_dataset=outcome,
            intervention_dataset=intervention,
            num_samples=5,
        )

>       ci.load_guide(forward_shift=2)

/Users/Admin/Documents/cities/tests/test_inference.py:110: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/Admin/Documents/cities/cities/queries/causal_insight.py:99: in load_guide
    self.guide = dill.load(file)
/Users/Admin/Documents/cities/venv/lib/python3.12/site-packages/dill/_dill.py:289: in load
    return Unpickler(file, ignore=ignore, **kwds).load()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <dill._dill.Unpickler object at 0x177a33a80>

    def load(self): #NOTE: if settings change, need to update attributes
>       obj = StockUnpickler.load(self)
E       AttributeError: 'CondIndepStackFrame' object has no attribute '__dict__'. Did you mean: '__dir__'?

/Users/Admin/Documents/cities/venv/lib/python3.12/site-packages/dill/_dill.py:444: AttributeError
_____________________________________ test_smoke_CausalInsigth[2-industry_real_estate_total-spending_transportation] ______________________________________

intervention = 'spending_transportation', outcome = 'industry_real_estate_total', shift = 2

    @pytest.mark.parametrize("intervention", interventions)
    @pytest.mark.parametrize("outcome", outcomes)
    @pytest.mark.parametrize("shift", shifts)
    def test_smoke_CausalInsigth(intervention, outcome, shift):
        ci = CausalInsight(
            outcome_dataset=outcome,
            intervention_dataset=intervention,
            num_samples=5,
        )

>       ci.load_guide(forward_shift=2)

/Users/Admin/Documents/cities/tests/test_inference.py:110: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/Admin/Documents/cities/cities/queries/causal_insight.py:99: in load_guide
    self.guide = dill.load(file)
/Users/Admin/Documents/cities/venv/lib/python3.12/site-packages/dill/_dill.py:289: in load
    return Unpickler(file, ignore=ignore, **kwds).load()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <dill._dill.Unpickler object at 0x177a33bb0>

    def load(self): #NOTE: if settings change, need to update attributes
>       obj = StockUnpickler.load(self)
E       AttributeError: 'CondIndepStackFrame' object has no attribute '__dict__'. Did you mean: '__dir__'?

/Users/Admin/Documents/cities/venv/lib/python3.12/site-packages/dill/_dill.py:444: AttributeError
_____________________________________ test_smoke_CausalInsigth[3-industry_real_estate_total-spending_transportation] ______________________________________

intervention = 'spending_transportation', outcome = 'industry_real_estate_total', shift = 3

    @pytest.mark.parametrize("intervention", interventions)
    @pytest.mark.parametrize("outcome", outcomes)
    @pytest.mark.parametrize("shift", shifts)
    def test_smoke_CausalInsigth(intervention, outcome, shift):
        ci = CausalInsight(
            outcome_dataset=outcome,
            intervention_dataset=intervention,
            num_samples=5,
        )

>       ci.load_guide(forward_shift=2)

/Users/Admin/Documents/cities/tests/test_inference.py:110: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/Admin/Documents/cities/cities/queries/causal_insight.py:99: in load_guide
    self.guide = dill.load(file)
/Users/Admin/Documents/cities/venv/lib/python3.12/site-packages/dill/_dill.py:289: in load
    return Unpickler(file, ignore=ignore, **kwds).load()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <dill._dill.Unpickler object at 0x177a33360>

    def load(self): #NOTE: if settings change, need to update attributes
>       obj = StockUnpickler.load(self)
E       AttributeError: 'CondIndepStackFrame' object has no attribute '__dict__'. Did you mean: '__dir__'?

/Users/Admin/Documents/cities/venv/lib/python3.12/site-packages/dill/_dill.py:444: AttributeError
================================================================= short test summary info =================================================================
FAILED tests/test_inference.py::test_smoke_CausalInsigth[1-industry_real_estate_total-spending_transportation] - AttributeError: 'CondIndepStackFrame' object has no attribute '__dict__'. Did you mean: '__dir__'?
FAILED tests/test_inference.py::test_smoke_CausalInsigth[2-industry_real_estate_total-spending_transportation] - AttributeError: 'CondIndepStackFrame' object has no attribute '__dict__'. Did you mean: '__dir__'?
FAILED tests/test_inference.py::test_smoke_CausalInsigth[3-industry_real_estate_total-spending_transportation] - AttributeError: 'CondIndepStackFrame' object has no attribute '__dict__'. Did you mean: '__dir__'?

Installing pyro-ppl==1.8.5 resolves the test failures.

rfl-urbaniak commented 2 weeks ago

Yes. I was just about to post this issue myself, thanks! For now, let's still use 1.8.5. Meanwhile, we're building more general models while testing them with pyro-ppl==1.9.1, of which the existing ones should be a particular case. If this works out, both the model and this test will be replaced.