Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment to chainlet DeploymentContext #1214

Merged

Conversation

spal1
Copy link
Collaborator

@spal1 spal1 commented Oct 30, 2024

Needed to revert my previous changes because they were not compatible with older context builder versions #1213

🚀 What

Adds an environment parameter to the chainlet DeploymentContext which can be accessed in a chainlet's __init__.
The environment of a chainlet can now be accessed by doing the following:

def __init__(
    self,
    # Adding the `context` argument, allows us to access the environment
    context: chains.DeploymentContext = chains.depends_context(),
) -> None:
    self._environment: Optional[definitions.Environment] = context.environment   

We need to add the environment field to DeploymentContext in a backwards-compatible manner, which is why it defaults to None in this PR. We can clean this up once dev, staging, and production are on a truss context builder version that includes these changes.

Backwards-compatibility test (using production's default context builder version)
Ran poetry run truss chains push truss-chains/truss_chains/example_chainlet.py
image

Copy link

linear bot commented Oct 30, 2024

@spal1 spal1 force-pushed the samiksha/bt-12428-add-environment-to-chainsdeploymentcontext branch from 1954110 to 3b59def Compare October 30, 2024 22:58
@spal1 spal1 marked this pull request as ready for review October 30, 2024 23:06
@spal1 spal1 merged commit fd10a6e into main Oct 31, 2024
5 checks passed
@spal1 spal1 deleted the samiksha/bt-12428-add-environment-to-chainsdeploymentcontext branch October 31, 2024 15:25
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.

2 participants