Compare commits

..
Author SHA1 Message Date
dependabot[bot] 8ef9d08c6c Update psycopg-pool requirement from >=3.1.0 to >=3.3.3 (#3099)
Updates the requirements on [psycopg-pool](https://github.com/psycopg/psycopg) to permit the latest version.
- [Changelog](https://github.com/psycopg/psycopg/blob/master/docs/news.rst)
- [Commits](https://github.com/psycopg/psycopg/compare/3.1...3.3.3)

---
updated-dependencies:
- dependency-name: psycopg-pool
  dependency-version: 3.3.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-19 16:10:02 +01:00
dependabot[bot] 6baeca873e Update langchain requirement from >=1.2.10 to >=1.5.0 (#3097)
Updates the requirements on [langchain](https://github.com/langchain-ai/langchain) to permit the latest version.
- [Release notes](https://github.com/langchain-ai/langchain/releases)
- [Commits](https://github.com/langchain-ai/langchain/compare/langchain==1.2.10...langchain==1.5.0)

---
updated-dependencies:
- dependency-name: langchain
  dependency-version: 1.5.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-19 16:09:39 +01:00
dependabot[bot] f727847112 Update telnetlib3 requirement from <6,==5.0.1 to ==5.0.2 (#3096)
Updates the requirements on [telnetlib3](https://github.com/jquast/telnetlib3) to permit the latest version.
- [Release notes](https://github.com/jquast/telnetlib3/releases)
- [Changelog](https://github.com/jquast/telnetlib3/blob/master/docs/history.rst)
- [Commits](https://github.com/jquast/telnetlib3/compare/5.0.1...5.0.2)

---
updated-dependencies:
- dependency-name: telnetlib3
  dependency-version: 5.0.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-19 16:09:05 +01:00
dependabot[bot] a2c1fd3b3e Bump pytest-asyncio from 1.4.1 to 1.5.0 (#3100)
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 1.4.1 to 1.5.0.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v1.4.1...v1.5.0)

---
updated-dependencies:
- dependency-name: pytest-asyncio
  dependency-version: 1.5.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-19 16:07:06 +01:00
Guobin Yue b23a47a460 Count closed project statistics from the topology file (#3101)
A closed project keeps no nodes, links or drawings in memory, so the
stats endpoint returned all zeros until the project was opened again.
When the project is closed, read the .gns3 file and count the scene
elements from it. When the file cannot be read (for example a project
that was never dumped), fall back to the in-memory counts.

Fixes #1836
2026-11-19 15:51:33 +01:00
5 changed files with 133 additions and 5 deletions

No files matched your search

+2 -2
View File
@@ -7,7 +7,7 @@
# Core AI and Automation Framework
# Note: aiosqlite is in core requirements.txt
langchain>=1.2.10
langchain>=1.5.0
langchain-core>=1.7.3
langgraph>=1.2.19
langgraph-checkpoint>=4.0.0
@@ -42,7 +42,7 @@ python-dotenv>=1.2.4
# Authentication
PyJWT>=2.15.1
psycopg-pool>=3.1.0
psycopg-pool>=3.3.3
# Skills Repository Management
PyYAML>=6.0.3
+1 -1
View File
@@ -1,6 +1,6 @@
pytest==9.2.0
pytest-timeout==2.4.0
pytest-asyncio==1.4.1
pytest-asyncio==1.5.0
httpx==0.28.1
httpx_ws==0.9.0
pytest-random-order==1.2.0 # opt-in: --random-order --random-order-bucket=global (legacy suites are not shuffle-clean yet, see .claude/skills/gns3-api-test-writing)
+36
View File
@@ -2495,7 +2495,17 @@ class Project:
return new_node
def stats(self):
"""
Return the project statistics.
A closed project keeps no scene elements in memory: the counts come
from the topology file instead (issue #1836).
"""
if self._status == "closed":
stats = self._stats_from_topology_file()
if stats is not None:
return stats
return {
"nodes": len(self._nodes),
"links": len(self._links),
@@ -2504,6 +2514,32 @@ class Project:
"markers": sum(len(link.markers) for link in self._links.values()),
}
def _stats_from_topology_file(self):
"""
Count the scene elements from the .gns3 file. The snapshots are
already restored from the snapshot config, and the markers are
counted from the per-link markers persisted with each link. Return
None when the file cannot be read (e.g. a project never dumped), so
the caller falls back to the in-memory counts.
"""
try:
with open(self.topology_file, encoding="utf-8") as f:
topology = json.load(f)
except (OSError, UnicodeDecodeError, ValueError) as e:
log.warning(f"Could not read the topology file of project '{self._name}' for the statistics: {e}")
return None
scene = topology.get("topology") or {}
links = scene.get("links") or []
return {
"nodes": len(scene.get("nodes") or []),
"links": len(links),
"drawings": len(scene.get("drawings") or []),
"snapshots": len(self._snapshots),
"markers": sum(len(link.get("markers") or {}) for link in links),
}
def asdict(self):
return {
"name": self._name,
+2 -2
View File
@@ -17,13 +17,13 @@ alembic==1.20.1
bcrypt==5.0.0
joserfc==1.7.7
email-validator==2.3.0
watchdog==7.1.0 # upgrading to v7.0.0 creates issues
watchdog==6.0.0 # upgrading to v7.0.0 creates issues
zstandard==0.25.0
platformdirs>=4.14.2
truststore>=0.10.5
# Shared dependencies (also used by AI Copilot)
telnetlib3==5.0.1,<6
telnetlib3==5.0.2
asyncssh>=2.24.1,<3
typing-extensions>=4.16.0
requests>=2.34.2
+92
View File
@@ -1417,3 +1417,95 @@ async def test_restore_deferred_links(project):
assert link._deferred is False
assert link.create.called is True
async def _populate_scene(project):
"""
Add two nodes, a link between them and a drawing to a project.
"""
compute = MagicMock()
compute.id = "local"
response = MagicMock()
response.json = {"console": 2048}
compute.post = AsyncioMagicMock(return_value=response)
node1 = await project.add_node(compute, "n1", None, node_type="vpcs", properties={})
node2 = await project.add_node(compute, "n2", None, node_type="vpcs", properties={})
node1._ports = [EthernetPort("E0", 0, 0, 0)]
node2._ports = [EthernetPort("E0", 0, 1, 0)]
link = await project.add_link()
await link.add_node(node1, 0, 0)
with asyncio_patch("gns3server.controller.udp_link.UDPLink.create"):
await link.add_node(node2, 1, 0)
project.emit_notification = MagicMock()
await project.add_drawing(None, svg="<svg></svg>")
return link
@pytest.mark.asyncio
async def test_stats_closed_project_counts_from_topology_file(controller, project):
"""
A closed project has no scene elements in memory: the stats must come
from the .gns3 file (issue #1836).
"""
await _populate_scene(project)
project.dump()
# same net effect as close(): the in-memory collections are emptied
project.reset()
project._status = "closed"
stats = project.stats()
assert stats["nodes"] == 2
assert stats["links"] == 1
assert stats["drawings"] == 1
assert stats["snapshots"] == 0
assert stats["markers"] == 0
@pytest.mark.asyncio
async def test_stats_closed_project_counts_markers_from_topology_file(controller, project):
"""
The markers of a closed project are counted from the per-link markers
persisted in the .gns3 file.
"""
link = await _populate_scene(project)
link.markers["http"] = {"bpf": "tcp port 80", "tag": "HTTP"}
project.dump()
project.reset()
project._status = "closed"
assert project.stats()["markers"] == 1
@pytest.mark.asyncio
async def test_stats_closed_project_without_topology_file(controller, project):
"""
A project never dumped (no .gns3 file yet) falls back to the in-memory
counts instead of raising.
"""
project._status = "closed"
assert project.stats() == {"nodes": 0, "links": 0, "drawings": 0, "snapshots": 0, "markers": 0}
@pytest.mark.asyncio
async def test_stats_opened_project_counts_from_memory(controller, project):
"""
An opened project reports the live in-memory counts.
"""
await _populate_scene(project)
project._status = "opened"
stats = project.stats()
assert stats["nodes"] == 2
assert stats["links"] == 1
assert stats["drawings"] == 1