-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dsl: Add "runtime_func" function decorator to enable a function to be…
… invoked as an eval expression function. Add tests for last few commits of dsl functionality.
- Loading branch information
Showing
10 changed files
with
313 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import unfurl | ||
import tosca | ||
from tosca import gb, Size | ||
from typing_extensions import reveal_type | ||
class ContainerService(tosca.nodes.Root): | ||
image: str | ||
url: str | ||
mem_size: tosca.Size | ||
name: str = tosca.CONSTRAINED | ||
|
||
@classmethod | ||
def _class_init(cls) -> None: | ||
# the proxy's backend is set to the container's url | ||
g: Size = 2 * gb | ||
bar: Size = g * 2.0 | ||
baz: Size = g * 2 | ||
wrong = g * "ddd" | ||
change_unit: Size = g * tosca.MB | ||
mismatch = g * 2.0 * tosca.kHz | ||
mismatch = g * tosca.HZ | ||
tosca.in_range(2*gb*2, 2*gb*2).apply_constraint(cls.mem_size) | ||
tosca.in_range(2*gb*2, 2*gb*2).apply_constraint(cls.url) | ||
baz + 50*tosca.GHz | ||
tosca.MB.as_int(baz) | ||
tosca.GHz.as_int(baz) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.