Skip to content

Commit

Permalink
fix: resolve lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alimosaed committed Nov 22, 2024
1 parent bddf09c commit 2727b93
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/message-queue-integrations/_app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ python = "^3.10"
llama-index-llms-openai = "^0.2.1"
llama-index-embeddings-openai = "^0.2.4"
llama-index-agent-openai = "^0.3.0"
llama-deploy = {version = "^0.2.1", extras = ["awssqs", "rabbitmq", "kafka", "redis", "solace"]}
llama-deploy = {version = "^0.3.0", extras = ["awssqs", "rabbitmq", "kafka", "redis", "solace"]}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ python -m examples.message-queue-integrations.solace.quick_start.interaction_con
``` bash
python -m examples.message-queue-integrations.solace.quick_start.interaction_multi_flows
```

Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@
SolaceMessageQueueConfig,
)


def load_env():
# Load environment variables from .env.solace file
dotenv_path = find_dotenv('.env.solace')
dotenv_path = find_dotenv(".env.solace")
if not dotenv_path:
raise FileNotFoundError('.env.solace file not found')
raise FileNotFoundError(".env.solace file not found")

load_dotenv(dotenv_path)


async def main():
await deploy_core(
control_plane_config=ControlPlaneConfig(),
message_queue_config=SolaceMessageQueueConfig(),
)


if __name__ == "__main__":
import asyncio

load_env()
asyncio.run(main())
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
step,
)


class ProgressEvent(Event):
progress: str


# create a dummy workflow
class PingWorkflow(Workflow):
@step()
Expand All @@ -28,12 +30,11 @@ async def run_step(self, ctx: Context, ev: StartEvent) -> StopEvent:

# stream events as steps run
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
ctx.write_event_to_stream(
ProgressEvent(progress=f"{current_time}: Ping Ping!")
)
ctx.write_event_to_stream(ProgressEvent(progress=f"{current_time}: Ping Ping!"))

return StopEvent(result=result)



# create a dummy workflow
class HelloWorkflow(Workflow):
@step()
Expand All @@ -43,20 +44,20 @@ async def run_step(self, ctx: Context, ev: StartEvent) -> StopEvent:
result = arg1 + "_result"

# stream events as steps run
ctx.write_event_to_stream(
ProgressEvent(progress="Hello!")
)
ctx.write_event_to_stream(ProgressEvent(progress="Hello!"))

return StopEvent(result=result)


def load_env():
# Load environment variables from .env.solace file
dotenv_path = find_dotenv('.env.solace')
dotenv_path = find_dotenv(".env.solace")
if not dotenv_path:
raise FileNotFoundError('.env.solace file not found')
raise FileNotFoundError(".env.solace file not found")

load_dotenv(dotenv_path)


async def main():
flow1 = deploy_workflow(
workflow=PingWorkflow(),
Expand All @@ -77,6 +78,7 @@ async def main():
# Run both tasks concurrently
await asyncio.gather(flow1, flow2)


if __name__ == "__main__":
load_env()
asyncio.run(main())
asyncio.run(main())
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Points to deployed control plane
client = LlamaDeployClient(ControlPlaneConfig())


def run_workflow(workflow_name: str):
"""Function to run the workflow in a separate thread."""
# Create a session
Expand All @@ -18,9 +19,10 @@ def run_workflow(workflow_name: str):
print(f"task_id for {workflow_name}:", task_id)
for event in session.get_task_result_stream(task_id):
print(f"task result for {workflow_name}:", event)

print(f"Done with {workflow_name}")


# Create and start threads for each workflow
threads = []
for _ in range(ITERATION_COUNT):
Expand All @@ -30,4 +32,4 @@ def run_workflow(workflow_name: str):

# Optionally, wait for all threads to complete
for thread in threads:
thread.join()
thread.join()
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Points to deployed control plane
client = LlamaDeployClient(ControlPlaneConfig())


def run_workflow(workflow_name: str):
"""Function to run the workflow in a separate thread."""
# Create a session
Expand All @@ -18,9 +19,10 @@ def run_workflow(workflow_name: str):
print(f"task_id for {workflow_name}:", task_id)
for event in session.get_task_result_stream(task_id):
print(f"task result for {workflow_name}:", event)

print(f"Done with {workflow_name}")


# Flows
flows = ["ping_workflow", "hello_workflow"]

Expand All @@ -34,4 +36,4 @@ def run_workflow(workflow_name: str):

# Optionally, wait for all threads to complete
for thread in threads:
thread.join()
thread.join()
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
print("task_id:", task_id)
for event in session.get_task_result_stream(task_id):
print("task result:", event)

time.sleep(SLEEP_TIME)
print("Done")

print("Done")

0 comments on commit 2727b93

Please sign in to comment.