Skip to content

Conversation

@devsjc
Copy link
Contributor

@devsjc devsjc commented Nov 5, 2025

  • Have you followed the Open Climate Fix Contribution Guidelines?
  • Have you referenced the Issue this PR addresses?
  • 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?.
  • Have you successfully run make lint with your changes locally?
  • Have you successfully run make gen with your changes locally?
  • Have you successfully run make test with your changes locally?

Fixes a bug whereby null metadata was not being correctly handled in the CreateForecast route.
Also

  • Renames the locations table for greater understandability.
  • Adds a target_period to each forecast object to track the forecast range
  • Simplifies GetForecastAtTimestamp query and route logic
  • Adds DeleteForeacst RPC

Closes #25

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

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":"2025-11-07T09:57:48Z","message":"Running migrations"}
goos: linux
goarch: amd64
pkg: github.com/openclimatefix/data-platform/internal/server/postgres
cpu: AMD EPYC 7763 64-Core Processor                
BenchmarkPostgresClient/6144000/GetForecastAsTimeseries-4         	     181	   6412454 ns/op
BenchmarkPostgresClient/6144000/GetForecastAtTimestamp-4          	      38	  29859384 ns/op
BenchmarkPostgresClient/6144000/GetObservationsAsTimeseries-4     	     880	   1279604 ns/op
BenchmarkPostgresClient/6144000/CreateForecast-4                  	     309	   3457436 ns/op
PASS
ok  	github.com/openclimatefix/data-platform/internal/server/postgres	114.622s
?   	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 │ bench-devsjc-location-table-rename.txt │
                                                     │     sec/op     │    sec/op      vs base                 │
PostgresClient/6144000/GetForecastAsTimeseries-4         4.826m ± ∞ ¹    6.412m ± ∞ ¹        ~ (p=1.000 n=1) ²
PostgresClient/6144000/GetForecastAtTimestamp-4         105.00m ± ∞ ¹    29.86m ± ∞ ¹        ~ (p=1.000 n=1) ²
PostgresClient/6144000/GetObservationsAsTimeseries-4     1.307m ± ∞ ¹    1.280m ± ∞ ¹        ~ (p=1.000 n=1) ²
PostgresClient/6144000/CreateForecast-4                  2.612m ± ∞ ¹    3.457m ± ∞ ¹        ~ (p=1.000 n=1) ²
geomean                                                  6.449m          5.395m        -16.35%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

@devsjc
Copy link
Contributor Author

devsjc commented Nov 5, 2025

Not sure why this has majorly sped up the benchmark for GetForecastAtTimestamp - going to investigate tomorrow.

@devsjc devsjc changed the title fix(dataserver): Handle null metadata in CreateForecast feat(dataserver): Forecast target period tracking, simplifying Nov 7, 2025
@devsjc devsjc changed the title feat(dataserver): Forecast target period tracking, simplifying feat(dataserver): Forecast target period tracking; simplifications Nov 7, 2025
@devsjc
Copy link
Contributor Author

devsjc commented Nov 7, 2025

Modified the entire table and query structure to improve theGetForecastAtTimestamp query, and forecasts table at large; now the speedup is warranted!

@devsjc devsjc merged commit b7ab669 into main Nov 7, 2025
3 checks passed
@devsjc devsjc deleted the devsjc/location-table-rename branch November 7, 2025 10: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.

Name of location table causes confusion against the RPC message location objects

2 participants