Skip to content

feat[cartesian]: lazy annotated gtscript functions#2708

Open
romanc wants to merge 4 commits into
GridTools:mainfrom
romanc:romanc/lazy_functions
Open

feat[cartesian]: lazy annotated gtscript functions#2708
romanc wants to merge 4 commits into
GridTools:mainfrom
romanc:romanc/lazy_functions

Conversation

@romanc

@romanc romanc commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

This PR extends the gtscript language with @gtscript.lazy_function() a decorator for gtscript functions where the annotation is delayed until the function is actually used inside a stencil or another function.

This allows support for types that aren't fully defined at the time when gtscript.functions are parsed (i.e. python parse time) by leveraging a hook to inject the right type before annotation happens. Details, motivation, and an example usage are in the ADR.

Tested in NDSL with PR NOAA-GFDL/NDSL#507.

Requirements

  • All fixes and/or new features come with corresponding tests.
  • Important design decisions have been documented in the appropriate ADR inside the docs/development/ADRs/ folder.

@romanc
romanc requested a review from twicki July 15, 2026 13:43
@romanc
romanc marked this pull request as draft July 15, 2026 14:42
@romanc

This comment was marked as outdated.

@romanc
romanc force-pushed the romanc/lazy_functions branch from a1b2f6a to 805945e Compare July 16, 2026 15:29
romanc added 4 commits July 17, 2026 10:11
This PR extends the `gtscript` language by adding `lazy_function` next
to `function`. `gtscript.lazy_funtion`s get annotated lazily, i.e. only
when used inside a stencil that gets annotated. In addition,
`gtscript.lazy_function`s give users hooks to optionally run code before
and after the function gets annotated. This feature could be used to
e.g. resolve temporary types that aren't fully defined yet when "normal"
`gtscript.function`s get annotated.
@romanc
romanc force-pushed the romanc/lazy_functions branch from 82cce46 to 44c2252 Compare July 17, 2026 08:11
@romanc
romanc marked this pull request as ready for review July 17, 2026 08:12
@romanc

romanc commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Alright - this is ready for show now.

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