Skip to content

feat: implement StreamCreateForecasts#185

Merged
devsjc merged 2 commits into
mainfrom
devsjc/streamcreateforecasts
Jul 15, 2026
Merged

feat: implement StreamCreateForecasts#185
devsjc merged 2 commits into
mainfrom
devsjc/streamcreateforecasts

Conversation

@devsjc

@devsjc devsjc commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Adds a new RPC, StreamCreateForecasts, that enables the quick creation of multiple forecasts at one time. These forecasts are all created in one atomic block, so if something goes wrong with any of them, none of them are entered into the database. This route and behaviour is a result of conversation with @dfulu.

Contribution Checklist

  • Have you followed the Open Climate Fix Contribution Guidelines?
  • Have you referenced the Issue this PR addresses, where applicable?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added a summary of the changes?
  • Have you written new tests for your changes, where applicable?
  • Have you successfully run make lint with your changes locally?
  • Have you successfully run make test with your changes locally?

Warning

PRs may be closed if all the above boxes are not checked.

Adds a new RPC, StreamCreateForecasts, that enables the quick creation
of multiple forecasts at one time. These forecasts are all created in
one atomic block, so if something goes wrong with any of them, none of
them are entered into the database. This route and behaviour is a result
of conversation with @dfulu.
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Benchmark Results

Benchmark results
?   	github.com/openclimatefix/data-platform/cmd	[no test files]
?   	github.com/openclimatefix/data-platform/internal/gen/ocf/dp	[no test files]
?   	github.com/openclimatefix/data-platform/internal/interceptors	[no test files]
PASS
ok  	github.com/openclimatefix/data-platform/internal/server/dummy	0.005s
{"level":"debug","time":"2026-07-15T10:21:31Z","message":"Completed migrations"}
goos: linux
goarch: amd64
pkg: github.com/openclimatefix/data-platform/internal/server/postgres
cpu: AMD EPYC 9V74 80-Core Processor                
BenchmarkPostgresClient/small/GetForecastAsTimeseries-4         	      51	  22161402 ns/op
BenchmarkPostgresClient/small/GetForecastAtTimestamp-4          	     192	   6118523 ns/op
BenchmarkPostgresClient/small/GetObservationsAsTimeseries-4     	     980	   1138055 ns/op
BenchmarkPostgresClient/small/CreateForecast-4                  	     129	   8954766 ns/op
BenchmarkPostgresClient/small/StreamForecastData-4              	      20	  54346252 ns/op
PASS
ok  	github.com/openclimatefix/data-platform/internal/server/postgres	59.697s
?   	github.com/openclimatefix/data-platform/internal/server/postgres/gen	[no test files]
Benchmark vs base branch
goos: linux
goarch: amd64
pkg: github.com/openclimatefix/data-platform/internal/server/postgres
cpu: AMD EPYC 7763 64-Core Processor                
                                                   │ bench-main.txt │
                                                   │     sec/op     │
PostgresClient/small/GetForecastAsTimeseries-4         24.16m ± ∞ ¹
PostgresClient/small/GetForecastAtTimestamp-4          6.560m ± ∞ ¹
PostgresClient/small/GetObservationsAsTimeseries-4     1.274m ± ∞ ¹
PostgresClient/small/CreateForecast-4                  11.24m ± ∞ ¹
PostgresClient/small/StreamForecastData-4              53.98m ± ∞ ¹
geomean                                                10.41m
¹ need >= 6 samples for confidence interval at level 0.95

cpu: AMD EPYC 9V74 80-Core Processor                
                                                   │ bench-devsjc-streamcreateforecasts.txt │
                                                   │                 sec/op                 │
PostgresClient/small/GetForecastAsTimeseries-4                                 22.16m ± ∞ ¹
PostgresClient/small/GetForecastAtTimestamp-4                                  6.119m ± ∞ ¹
PostgresClient/small/GetObservationsAsTimeseries-4                             1.138m ± ∞ ¹
PostgresClient/small/CreateForecast-4                                          8.955m ± ∞ ¹
PostgresClient/small/StreamForecastData-4                                      54.35m ± ∞ ¹
geomean                                                                        9.443m
¹ need >= 6 samples for confidence interval at level 0.95

@devsjc
devsjc merged commit 71bfa07 into main Jul 15, 2026
4 checks passed
@devsjc
devsjc deleted the devsjc/streamcreateforecasts branch July 15, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant