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

add substitute handler #3125

Merged
merged 5 commits into from
Jan 25, 2023
Merged

add substitute handler #3125

merged 5 commits into from
Jan 25, 2023

Conversation

thisiscam
Copy link
Contributor

Attempt at #3124, largely mimics the lift handler

Copy link
Member

@fritzo fritzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great and I especially like the name checking for usability!

  1. Could you explain the need for the _data_cache? Would this PR break if that were missing, or is it merely for speed?
  2. Could you add some unit tests in tests/poutine/test_poutines.py, perhaps forking ConditionHandlerTests?
  3. Could you add an entry in docs/source/pyro.poutine.rst (inserting in alphabetical order please 😉)
  4. Looks like you'll need to run make format to fix coding style (see CONTRIBUTING.md), that's why the lint stage is failing. You can test this locally via make lint.

@thisiscam
Copy link
Contributor Author

Hi @fritzo,

My guess is: It's probably ok to drop _data_cache, assuming nothing other than concrete values are passed into the substitution. E.g. we never substitute a distribution into a variable. Otherwise, we need to make sure that if there are multiple param calls, they are substituted to point to the same object.

TBH, I have not looked into Pyro's code too much, and was largely mimicing the lift handler.

For the test case, I'm not sure how ConditionHandlerTests is relevant. Could you explain? It might be easier to add a simple standalone test case, though.

@thisiscam
Copy link
Contributor Author

@fritzo I added some tests, but I don't know how to run the test locally... Sorry

make test

produces:

/pyro/poutine/handlers.py:docstring of pyro.poutine.handlers._make_handler.<locals>.handler:9:Unexpected indentation.

@fritzo
Copy link
Member

fritzo commented Oct 28, 2022

I'm not sure why your local make test failed, but it might be failing linting rather than hitting the real test. To run your particular tests you could try locally pytest tests/poutine/test_poutines.py

@fritzo
Copy link
Member

fritzo commented Jan 8, 2023

Hi @thisiscam, sorry this seems to have fallen off the radar and CI for some reason didn't trigger. Could you try merging in the dev branch and re-pushing?

merge in the dev (since CI didn't trigger last time)
@thisiscam
Copy link
Contributor Author

@fritzo Hi, sorry about the delay. I just merged dev and pushed to my branch.
Just posting here in case GitHub didn't send a notification.

Copy link
Member

@fritzo fritzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for working through the CI issues.

@fritzo fritzo merged commit 1678ee2 into pyro-ppl:dev Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants