Skip to content

Commit

Permalink
Merge pull request #46 from imjoy-team/fix-plugin-number
Browse files Browse the repository at this point in the history
Fix plugin_count
  • Loading branch information
oeway authored Nov 10, 2021
2 parents 5dc6298 + 3028140 commit 63fd99f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hypha/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.12.10"
"version": "0.12.11"
}
4 changes: 2 additions & 2 deletions hypha/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ def connected(plugin):
self._apps[page_id]["status"] = "connected"
asyncio.get_running_loop().create_task(check_ready(plugin, config))

def failed(config):
def failed(detail):
app_info["watch"] = False
fut.set_exception(Exception(config.detail))
fut.set_exception(Exception(detail))

plugin_event_bus.on("connected", connected)
plugin_event_bus.on("failed", failed)
Expand Down
7 changes: 5 additions & 2 deletions hypha/core/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,13 @@ def get_user_info_from_token(self, token):
# if the same user id does not exist
if user_info.id in self._all_users:
user_info = self._all_users[user_info.id]
else:
self._all_users[user_info.id] = user_info
return user_info

def add_user(self, user_info):
"""Add a user."""
if user_info.id not in self._all_users:
self._all_users[user_info.id] = user_info

def create_user_workspace(self, user_info, read_only: bool = False):
"""Create a workspace for the user."""
# only registered user can have persistent workspace
Expand Down
1 change: 1 addition & 0 deletions hypha/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ async def register_plugin(sid, config):
user_info,
event_bus,
)
core_interface.add_user(user_info)
user_info.add_plugin(plugin)
workspace.add_plugin(plugin)
event_bus.emit(
Expand Down
7 changes: 5 additions & 2 deletions tests/test_server_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,12 @@ async def test_non_persistent_workspace(socketio_server):
response = requests.get(f"{SIO_SERVER_URL}/api/stats")
assert response.status_code == 200
stats = response.json()
assert stats["plugin_count"] == 3
workspace_info = find_item(stats["workspaces"], "name", workspace)
assert workspace_info is not None
count = 0
for workspace in stats["workspaces"]:
count += len(workspace["plugins"])
assert stats["plugin_count"] == count
plugins = workspace_info["plugins"]
assert find_item(plugins, "id", plugin.config["id"]) is not None

Expand All @@ -208,6 +211,6 @@ async def test_non_persistent_workspace(socketio_server):
response = requests.get(f"{SIO_SERVER_URL}/api/stats")
assert response.status_code == 200
stats = response.json()
assert stats["plugin_count"] == 1
workspace_info = find_item(stats["workspaces"], "name", workspace)
assert workspace_info is None
assert stats["plugin_count"] == count - 2

0 comments on commit 63fd99f

Please sign in to comment.