Skip to content

Commit 20fbe46

Browse files
authored
Add references to RxInferServer and Python SDK (#459)
* add references to python client * update benchmark figures * fix tests * update format check CI job * 🤖 Auto-format Julia code * update version to 4.4.1 * 2prev --------- Co-authored-by: bvdmitri <6557701+bvdmitri@users.noreply.github.com>
1 parent 8b0155b commit 20fbe46

29 files changed

+4485
-6052
lines changed

.github/workflows/CI.yml

Lines changed: 165 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ jobs:
4040
# PDF. Note, this should be the same directory as the input
4141
# paper.md
4242
path: paper/paper.pdf
43-
code-style:
44-
name: Code Style Suggestions
45-
runs-on: ubuntu-latest
46-
steps:
47-
- uses: julia-actions/julia-format@v3
4843
test:
4944
name: Tests ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
5045
runs-on: ${{ matrix.os }}
@@ -120,4 +115,169 @@ jobs:
120115
env:
121116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122117
LOG_USING_RXINFER: "false"
118+
format-check:
119+
name: Code Format Check
120+
runs-on: ubuntu-latest
121+
# Don't run on PRs that come from forks as they won't have permission to create PRs
122+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
123+
permissions:
124+
contents: write # Needed to push commits
125+
pull-requests: write # Needed to create PRs and write comments
126+
steps:
127+
- uses: actions/checkout@v4
128+
with:
129+
ref: ${{ github.head_ref }}
130+
token: ${{ secrets.GITHUB_TOKEN }}
131+
- uses: julia-actions/setup-julia@v2
132+
- uses: julia-actions/cache@v2
133+
134+
# Find existing format PR if any
135+
- name: Find existing format PR
136+
id: find_pr
137+
uses: actions/github-script@v7
138+
with:
139+
github-token: ${{ secrets.GITHUB_TOKEN }}
140+
script: |
141+
const prNumber = ${{ github.event.pull_request.number }};
142+
const owner = context.repo.owner;
143+
const repo = context.repo.repo;
144+
145+
// Look for open PRs with our auto-format branch pattern that targets this PR's branch
146+
const prs = await github.rest.pulls.list({
147+
owner,
148+
repo,
149+
state: 'open',
150+
base: '${{ github.head_ref }}'
151+
});
152+
153+
const formatPr = prs.data.find(pr => pr.head.ref.startsWith('auto-format-') &&
154+
pr.title === "🤖 Auto-format Julia code");
155+
156+
if (formatPr) {
157+
console.log(`Found existing format PR: #${formatPr.number}`);
158+
return formatPr.number;
159+
}
160+
161+
return '';
162+
163+
- name: Run formatter check
164+
id: format_check
165+
run: |
166+
if ! make lint; then
167+
echo "format_needs_fix=true" >> $GITHUB_OUTPUT
168+
else
169+
echo "format_needs_fix=false" >> $GITHUB_OUTPUT
170+
fi
171+
172+
# Close any existing formatting PR if the check now passes
173+
- name: Close existing format PR if check passes
174+
if: steps.format_check.outputs.format_needs_fix == 'false' && steps.find_pr.outputs.result != ''
175+
uses: actions/github-script@v7
176+
with:
177+
github-token: ${{ secrets.GITHUB_TOKEN }}
178+
script: |
179+
const formatPrNumber = Number(${{ steps.find_pr.outputs.result }});
180+
181+
if (formatPrNumber === 0) {
182+
return;
183+
}
184+
185+
const owner = context.repo.owner;
186+
const repo = context.repo.repo;
187+
188+
// Close the PR with a comment
189+
await github.rest.issues.createComment({
190+
owner,
191+
repo,
192+
issue_number: formatPrNumber,
193+
body: `Closing this PR as the code formatting issues in the original PR have been resolved.`
194+
});
195+
196+
await github.rest.pulls.update({
197+
owner,
198+
repo,
199+
pull_number: formatPrNumber,
200+
state: 'closed'
201+
});
202+
203+
console.log(`Closed format PR #${formatPrNumber} as the original PR now passes formatting checks.`);
204+
205+
- name: Apply formatter if needed
206+
if: steps.format_check.outputs.format_needs_fix == 'true'
207+
run: |
208+
make format
209+
210+
- name: Commit changes and create/update PR
211+
if: steps.format_check.outputs.format_needs_fix == 'true'
212+
uses: peter-evans/create-pull-request@v7
213+
with:
214+
token: ${{ secrets.GITHUB_TOKEN }}
215+
commit-message: "🤖 Auto-format Julia code"
216+
title: "🤖 Auto-format Julia code"
217+
body: |
218+
This PR was automatically created to fix Julia code formatting issues.
219+
220+
The formatting was applied using JuliaFormatter according to the project's style guidelines.
221+
222+
Please review the changes and merge if appropriate.
223+
branch: auto-format-${{ github.event.pull_request.number }}
224+
base: ${{ github.head_ref }}
225+
delete-branch: true
226+
labels: |
227+
automated pr
228+
code style
229+
id: create-pr
230+
231+
- name: Comment on original PR
232+
if: steps.format_check.outputs.format_needs_fix == 'true' && steps.create-pr.outputs.pull-request-number && steps.find_pr.outputs.result == ''
233+
uses: actions/github-script@v7
234+
with:
235+
github-token: ${{ secrets.GITHUB_TOKEN }}
236+
script: |
237+
const prNumber = ${{ github.event.pull_request.number }};
238+
const formatPrNumber = ${{ steps.create-pr.outputs.pull-request-number }};
239+
const formatPrUrl = `https://github.com/${{ github.repository }}/pull/${formatPrNumber}`;
240+
241+
await github.rest.issues.createComment({
242+
owner: context.repo.owner,
243+
repo: context.repo.repo,
244+
issue_number: prNumber,
245+
body: `## 🤖 Code Formatting
246+
247+
This PR has some code formatting issues. I've created [PR #${formatPrNumber}](${formatPrUrl}) with the necessary formatting changes.
248+
249+
You can merge that PR into this branch to fix the code style check.
250+
251+
Alternatively, you can run \`make format\` locally and push the changes yourself.`
252+
});
253+
254+
- name: Comment on original PR for updated formatting PR
255+
if: steps.format_check.outputs.format_needs_fix == 'true' && steps.create-pr.outputs.pull-request-number && steps.find_pr.outputs.result != ''
256+
uses: actions/github-script@v7
257+
with:
258+
github-token: ${{ secrets.GITHUB_TOKEN }}
259+
script: |
260+
const prNumber = ${{ github.event.pull_request.number }};
261+
const formatPrNumber = ${{ steps.create-pr.outputs.pull-request-number }};
262+
const formatPrUrl = `https://github.com/${{ github.repository }}/pull/${formatPrNumber}`;
263+
264+
await github.rest.issues.createComment({
265+
owner: context.repo.owner,
266+
repo: context.repo.repo,
267+
issue_number: prNumber,
268+
body: `## 🤖 Code Formatting
269+
270+
Your PR still has some code formatting issues. I've updated [PR #${formatPrNumber}](${formatPrUrl}) with the necessary formatting changes.
271+
272+
You can merge that PR into this branch to fix the code style check.
273+
274+
Alternatively, you can run \`make format\` locally and push the changes yourself.`
275+
});
276+
277+
# Fail the job if formatting was needed and applied
278+
- name: Fail if formatting was needed
279+
if: steps.format_check.outputs.format_needs_fix == 'true'
280+
run: |
281+
echo "::error::Code formatting issues detected. A PR with fixes has been created, but this check is failing to indicate that formatting needs to be fixed."
282+
exit 1
123283

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RxInfer"
22
uuid = "86711068-29c9-4ff7-b620-ae75d7495b3d"
33
authors = ["Bagaev Dmitry <d.v.bagaev@tue.nl> and contributors"]
4-
version = "4.4.0"
4+
version = "4.4.1"
55

66
[deps]
77
BayesBase = "b4ee3484-f114-42fe-b91c-797d54a0c67e"

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
Given a probabilistic model, RxInfer allows for an efficient message-passing based Bayesian inference. It uses the model structure to generate an algorithm that consists of a sequence of local computations on a factor graph representation of the model.
2121

22+
> [!NOTE]
23+
> RxInfer can also be used from Python through our [client-server infrastructure](#client-server-infrastructure) and [Python SDK](https://github.com/lazydynamics/RxInferClient.py).
24+
2225
### Performance and scalability
2326

2427
RxInfer.jl has been designed with a focus on efficiency, scalability and maximum performance for running Bayesian inference with message passing. Below is a comparison between RxInfer.jl and Turing.jl on latent state estimation in a linear multi-variate Gaussian state-space model. [Turing.jl](https://github.com/TuringLang/Turing.jl) is a state-of-the-art Julia-based general-purpose probabilistic programming package and is capable of running inference in a broader class of models. Still, RxInfer.jl executes the inference task in [various models](https://examples.rxinfer.com) faster and more accurately. RxInfer.jl accomplishes this by taking advantage of any conjugate likelihood-prior pairings in the model, which have analytical posteriors that are known by RxInfer.jl. As a result, in models with conjugate pairings, RxInfer.jl often beats general-purpose probabilistic programming packages in terms of computational load, speed, memory and accuracy. Note, however, that RxInfer.jl also supports non-conjugate inference and is continually improving in order to support a larger class of models.
@@ -179,6 +182,29 @@ The `RxInfer` framework consists of four *core* packages developed by [ReactiveB
179182
- [`ExponentialFamily.jl`](https://github.com/reactivebayes/ExponentialFamily.jl) - package for exponential family distributions
180183
- [`Rocket.jl`](https://github.com/reactivebayes/Rocket.jl) - reactive extensions package for Julia
181184

185+
## Client-Server Infrastructure
186+
187+
RxInfer can be deployed as a RESTful API service using [`RxInferServer.jl`](https://github.com/lazydynamics/RxInferServer), which provides:
188+
189+
- OpenAPI-compliant RESTful API endpoints for RxInfer models
190+
- Support for model instance management and inference execution
191+
- Real-time inference capabilities
192+
- Comprehensive API documentation at [server.rxinfer.com](https://server.rxinfer.com)
193+
194+
### Client SDKs
195+
196+
To interact with RxInferServer, you can use one of the following SDKs:
197+
198+
- **Python SDK**: [`RxInferClient.py`](https://github.com/lazydynamics/RxInferClient.py) - A Python client for interacting with RxInferServer
199+
- **Julia SDK**: Included in the RxInferServer repository
200+
201+
Both SDKs provide a convenient interface to:
202+
- Create and manage model instances
203+
- Execute inference tasks
204+
- Monitor inference progress
205+
- Handle authentication and API keys
206+
- Process results in a native format
207+
182208
# Where to go next?
183209

184210
There are a set of [examples](https://examples.rxinfer.com/) available in the `RxInferExamples.jl` repository that demonstrate the more advanced features of the package. Alternatively, you can head to the [documentation](https://docs.rxinfer.com) that provides more detailed information of how to use `RxInfer` to specify more complex probabilistic models.

0 commit comments

Comments
 (0)