Skip to content

Commit

Permalink
fixup! Allow simulation customization in web API
Browse files Browse the repository at this point in the history
  • Loading branch information
guillett committed Feb 1, 2024
1 parent ca096dc commit a6c5da3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 41.5.0 [#1204](https://github.com/openfisca/openfisca-core/pull/1204)

#### New feature

- Introduce `simulation_configurator`
- Allow simulation customization in web API

```python
def simulation_configurator(simulation):
simulation.max_spiral_loops = 4

application = create_app(tax_benefit_system,
simulation_configurator=simulation_configurator)
```

### 41.4.2 [#1203](https://github.com/openfisca/openfisca-core/pull/1203)

#### Technical changes
Expand Down
4 changes: 2 additions & 2 deletions openfisca_web_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def calculate():
request.on_json_loading_failed = handle_invalid_json
input_data = request.get_json()
try:
result = handlers.calculate(tax_benefit_system, input_data, simulation_configurator)
result = handlers.calculate(tax_benefit_system, input_data)
except (SituationParsingError, PeriodMismatchError) as e:
abort(make_response(jsonify(e.error), e.code or 400))
except (UnicodeEncodeError, UnicodeDecodeError) as e:
Expand All @@ -186,7 +186,7 @@ def trace():
request.on_json_loading_failed = handle_invalid_json
input_data = request.get_json()
try:
result = handlers.trace(tax_benefit_system, input_data, simulation_configurator)
result = handlers.trace(tax_benefit_system, input_data)
except (SituationParsingError, PeriodMismatchError) as e:
abort(make_response(jsonify(e.error), e.code or 400))
return jsonify(result)
Expand Down
2 changes: 1 addition & 1 deletion openfisca_web_api/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def calculate(self, tax_benefit_system, input_data: dict) -> dict:

return input_data

def trace(self, tax_benefit_system, input_data, simulation_configurator=None):
def trace(self, tax_benefit_system, input_data):
simulation = SimulationBuilder().build_from_entities(tax_benefit_system, input_data)
self.simulation_configurator(simulation)
simulation.trace = True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

setup(
name="OpenFisca-Core",
version="41.4.2",
version="41.5.0",
author="OpenFisca Team",
author_email="[email protected]",
classifiers=[
Expand Down

0 comments on commit a6c5da3

Please sign in to comment.