Merge branch 'dev' into COG-793-metadata-rework
This commit is contained in:
commit
bd3a5a758c
2 changed files with 66 additions and 6 deletions
42
.github/workflows/test_dynamic_steps_example_windows.yml
vendored
Normal file
42
.github/workflows/test_dynamic_steps_example_windows.yml
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
name: test
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
types: [labeled, synchronize]
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run_notebook_test_windows:
|
||||||
|
name: windows-latest
|
||||||
|
runs-on: windows-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@master
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.11.x'
|
||||||
|
|
||||||
|
- name: Install Poetry
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install poetry
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
poetry install --no-interaction --all-extras
|
||||||
|
|
||||||
|
- name: Execute Python Example
|
||||||
|
env:
|
||||||
|
ENV: 'dev'
|
||||||
|
PYTHONFAULTHANDLER: 1
|
||||||
|
LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
|
run: poetry run python ./examples/python/dynamic_steps_example.py
|
||||||
|
|
@ -250,7 +250,8 @@ class NetworkXAdapter(GraphDBInterface):
|
||||||
graph_data = nx.readwrite.json_graph.node_link_data(self.graph)
|
graph_data = nx.readwrite.json_graph.node_link_data(self.graph)
|
||||||
|
|
||||||
async with aiofiles.open(file_path, "w") as file:
|
async with aiofiles.open(file_path, "w") as file:
|
||||||
await file.write(json.dumps(graph_data, cls=JSONEncoder))
|
json_data = json.dumps(graph_data, cls=JSONEncoder)
|
||||||
|
await file.write(json_data)
|
||||||
|
|
||||||
async def load_graph_from_file(self, file_path: str = None):
|
async def load_graph_from_file(self, file_path: str = None):
|
||||||
"""Asynchronously load the graph from a file in JSON format."""
|
"""Asynchronously load the graph from a file in JSON format."""
|
||||||
|
|
@ -265,19 +266,32 @@ class NetworkXAdapter(GraphDBInterface):
|
||||||
graph_data = json.loads(await file.read())
|
graph_data = json.loads(await file.read())
|
||||||
for node in graph_data["nodes"]:
|
for node in graph_data["nodes"]:
|
||||||
try:
|
try:
|
||||||
node["id"] = UUID(node["id"])
|
if not isinstance(node["id"], UUID):
|
||||||
|
node["id"] = UUID(node["id"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
pass
|
pass
|
||||||
if "updated_at" in node:
|
|
||||||
|
if isinstance(node.get("updated_at"), int):
|
||||||
|
node["updated_at"] = datetime.fromtimestamp(
|
||||||
|
node["updated_at"] / 1000, tz=timezone.utc
|
||||||
|
)
|
||||||
|
elif isinstance(node.get("updated_at"), str):
|
||||||
node["updated_at"] = datetime.strptime(
|
node["updated_at"] = datetime.strptime(
|
||||||
node["updated_at"], "%Y-%m-%dT%H:%M:%S.%f%z"
|
node["updated_at"], "%Y-%m-%dT%H:%M:%S.%f%z"
|
||||||
)
|
)
|
||||||
|
|
||||||
for edge in graph_data["links"]:
|
for edge in graph_data["links"]:
|
||||||
try:
|
try:
|
||||||
source_id = UUID(edge["source"])
|
if not isinstance(edge["source"], UUID):
|
||||||
target_id = UUID(edge["target"])
|
source_id = UUID(edge["source"])
|
||||||
|
else:
|
||||||
|
source_id = edge["source"]
|
||||||
|
|
||||||
|
if not isinstance(edge["target"], UUID):
|
||||||
|
target_id = UUID(edge["target"])
|
||||||
|
else:
|
||||||
|
target_id = edge["target"]
|
||||||
|
|
||||||
edge["source"] = source_id
|
edge["source"] = source_id
|
||||||
edge["target"] = target_id
|
edge["target"] = target_id
|
||||||
|
|
@ -287,7 +301,11 @@ class NetworkXAdapter(GraphDBInterface):
|
||||||
print(e)
|
print(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if "updated_at" in edge:
|
if isinstance(edge["updated_at"], int): # Handle timestamp in milliseconds
|
||||||
|
edge["updated_at"] = datetime.fromtimestamp(
|
||||||
|
edge["updated_at"] / 1000, tz=timezone.utc
|
||||||
|
)
|
||||||
|
elif isinstance(edge["updated_at"], str):
|
||||||
edge["updated_at"] = datetime.strptime(
|
edge["updated_at"] = datetime.strptime(
|
||||||
edge["updated_at"], "%Y-%m-%dT%H:%M:%S.%f%z"
|
edge["updated_at"], "%Y-%m-%dT%H:%M:%S.%f%z"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue