Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Index
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Llama Index
Commits
82fd82e8
Unverified
Commit
82fd82e8
authored
1 month ago
by
Massimiliano Pippi
Committed by
GitHub
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: take step workers into account when running a workflow step-wise (#17942)
parent
02667803
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llama-index-core/llama_index/core/workflow/context.py
+19
-5
19 additions, 5 deletions
llama-index-core/llama_index/core/workflow/context.py
with
19 additions
and
5 deletions
llama-index-core/llama_index/core/workflow/context.py
+
19
−
5
View file @
82fd82e8
...
...
@@ -3,7 +3,18 @@ import json
import
uuid
import
warnings
from
collections
import
defaultdict
from
typing
import
TYPE_CHECKING
,
Any
,
Dict
,
List
,
Optional
,
Set
,
Tuple
,
Type
,
TypeVar
from
typing
import
(
TYPE_CHECKING
,
Any
,
DefaultDict
,
Dict
,
List
,
Optional
,
Set
,
Tuple
,
Type
,
TypeVar
,
)
from
.context_serializers
import
BaseSerializer
,
JsonSerializer
from
.decorators
import
StepConfig
...
...
@@ -58,8 +69,9 @@ class Context:
# an existing context.
self
.
_in_progress
:
Dict
[
str
,
List
[
Event
]]
=
defaultdict
(
list
)
# Keep track of the steps currently running. This is only valid when a
# workflow is running and won't be serialized.
self
.
_currently_running_steps
:
Set
[
str
]
=
set
()
# workflow is running and won't be serialized. Note that a single step
# might have multiple workers, so we keep a counter.
self
.
_currently_running_steps
:
DefaultDict
[
str
,
int
]
=
defaultdict
(
int
)
# Streaming machinery
self
.
_streaming_queue
:
asyncio
.
Queue
=
asyncio
.
Queue
()
# Global data storage
...
...
@@ -207,11 +219,13 @@ class Context:
async
def
add_running_step
(
self
,
name
:
str
)
->
None
:
async
with
self
.
lock
:
self
.
_currently_running_steps
.
add
(
name
)
self
.
_currently_running_steps
[
name
]
+=
1
async
def
remove_running_step
(
self
,
name
:
str
)
->
None
:
async
with
self
.
lock
:
self
.
_currently_running_steps
.
remove
(
name
)
self
.
_currently_running_steps
[
name
]
-=
1
if
self
.
_currently_running_steps
[
name
]
==
0
:
del
self
.
_currently_running_steps
[
name
]
async
def
running_steps
(
self
)
->
List
[
str
]:
async
with
self
.
lock
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment