Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Yangtong Xu committed Mar 27, 2024
1 parent 24dae1b commit 4f07c87
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/promptflow/promptflow/azure/_storage/cosmosdb/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class Span:

name: str = None
context: dict = None
kind: str = None
Expand Down Expand Up @@ -71,16 +70,19 @@ def to_dict(self) -> Dict[str, Any]:
return {k: v for k, v in self.__dict__.items() if v}

def _persist_events(self, blob_container_client: ContainerClient, blob_base_uri: str):
idx = 0
for event in self.events:
if not blob_base_uri.endswith("/"):
blob_base_uri += "/"

for idx, event in enumerate(self.events):
event_data = json.dumps(event)
blob_client = blob_container_client.get_blob_client(self._event_path(idx))
blob_client.upload_blob(event_data)

event[SpanEventFieldName.ATTRIBUTES] = {}
self.external_event_data_uris.append(f"{blob_base_uri}{self._event_path(idx)}")

idx += 1
EVENT_PATH_PREFIX = ".promptflow/.trace"

def _event_path(self, idx: int) -> str:
return f".promptflow/.trace/{self.collection_id}/{self.context[SpanContextFieldName.TRACE_ID]}/{self.id}/{idx}"
trace_id = self.context[SpanContextFieldName.TRACE_ID]
return f"{self.EVENT_PATH_PREFIX}/{self.collection_id}/{trace_id}/{self.id}/{idx}"

0 comments on commit 4f07c87

Please sign in to comment.