-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Refactor/services callbacks #3338
base: develop
Are you sure you want to change the base?
Conversation
This PR replaces PR #3337. PR 3337 updated the stan::services::util methods and stan::services::sample::hmc_nuts_diag_e_adapt sampler to use the dispatcher object. The proof-of-concept unit test is configured to capture the initial parameters on the unconstrained scale, as well as the metric, sample, and diagnostics. This PR anticipates further refactoring of the stan::services layer before trying to replace callback writers with a dispatcher. |
Jenkins Console Log Machine informationNo LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focalCPU: G++: Clang: |
Submission Checklist
./runTests.py src/test/unit
make cpplint
Summary
Adds a "dispatcher" object to stan::callbacks and utility function "configure_dispatcher" to stan::services::util, with unit tests for each.
The dispatcher object maps information types to callbacks. Because classes
callbacks::writer
andcallbacks::structured_writer
aren't compatible, it introduces a "channel" class which serves as a base type for all callbacks, with subclasseswriter_channel
andstructured_writer_channel
.The dispatcher provides methods
dispatch
,begin_record
andend_record
. The first argument for all methods is the information type. For methoddispatch
the remaining args correspond to the callbacks::writer's operator () overloads and the callbacks::structured_writer'swrite
methods. For methodsbegin_record
andend_record
, the remaing args correspond to the callbacks::structured_writer'sbegin_record
andend_record
, respectively.The function
configure_dispatcher
is used by clients to add information_type, callback pairs to the dispatcher's internal channel map. This allows clients to specify which information to save, if any.Intended Effect
This decouples the choice of outputs from the services layer API calls; instead of specifying output files the sample, the sampler diagnostics, and the adapted metric, etc., services calls take a single dispatcher object. The dispatcher introduces the base
channel
class which allows for the introduction of new kinds of callbacks, e.g., raw text writers, raw binary writers.How to Verify
Unit tests
Side Effects
N/A
Documentation
code comments
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Columbia University
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: