Skip to content

Commit

Permalink
[Framework] Allowing parent event context override (#601)
Browse files Browse the repository at this point in the history
# Description

What - Allowing parent event context override
Why - To allow using another event context attributes within task sub
threads

## Type of change

Please leave one option from the following and delete the rest:

- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] New Integration (non-breaking change which adds a new integration)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Non-breaking change (fix of existing functionality that will not
change current behavior)
- [ ] Documentation (added/updated documentation)

## Screenshots

Include screenshots from your environment showing how the resources of
the integration will look.

## API Documentation

Provide links to the API documentation used for this integration.
  • Loading branch information
omby8888 authored May 1, 2024
1 parent 42e0d31 commit fa5eaa0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

<!-- towncrier release notes start -->

## 0.5.16 (2024-05-01)

### Features

- Allowing override of parent event context in ocean's event context manager


## 0.5.15 (2024-04-30)

### Bug Fixes
Expand Down
5 changes: 4 additions & 1 deletion port_ocean/context/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,13 @@ async def event_context(
event_type: str,
trigger_type: TriggerType = "manual",
attributes: dict[str, Any] | None = None,
parent_override: EventContext | None = None,
) -> AsyncIterator[EventContext]:
attributes = attributes or {}
parent = parent_override or _event_context_stack.top
parent_attributes = parent.attributes if parent else {}

parent = _event_context_stack.top
attributes = {**parent_attributes, **(attributes or {})}
new_event = EventContext(
event_type,
trigger_type=trigger_type,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "port-ocean"
version = "0.5.15"
version = "0.5.16"
description = "Port Ocean is a CLI tool for managing your Port projects."
readme = "README.md"
homepage = "https://app.getport.io"
Expand Down

0 comments on commit fa5eaa0

Please sign in to comment.