nc-py-api 0.15.1__tar.gz → 0.16.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/CHANGELOG.md +10 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/PKG-INFO +1 -1
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_version.py +1 -1
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/providers/task_processing.py +94 -30
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/files/files.py +1 -1
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/pyproject.toml +2 -1
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/.gitignore +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/AUTHORS +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/LICENSE.txt +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/README.md +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/__init__.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_deffered_error.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_exceptions.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_misc.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_preferences.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_preferences_ex.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_session.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_talk_api.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/_theming.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/activity.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/apps.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/calendar.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/__init__.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/defs.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/events_listener.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/integration_fastapi.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/misc.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/occ_commands.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/persist_transformers_cache.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/providers/__init__.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/providers/providers.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/providers/speech_to_text.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/providers/text_processing.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/providers/translations.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/ui/__init__.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/ui/files_actions.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/ui/resources.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/ui/settings.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/ui/top_menu.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/ui/ui.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/ex_app/uvicorn_fastapi.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/files/__init__.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/files/_files.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/files/files_async.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/files/sharing.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/loginflow_v2.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/nextcloud.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/notes.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/notifications.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/options.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/talk.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/talk_bot.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/user_status.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/users.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/users_groups.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/weather_status.py +0 -0
- {nc_py_api-0.15.1 → nc_py_api-0.16.0}/nc_py_api/webhooks.py +0 -0
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.16.0 - 2024-08-12]
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- NextcloudApp: rework of TaskProcessing provider API. #284
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- `nc.files.makedirs` not working properly on Windows. #280 Thanks to @Wuli6
|
|
14
|
+
|
|
5
15
|
## [0.15.1 - 2024-07-30]
|
|
6
16
|
|
|
7
17
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: nc-py-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.0
|
|
4
4
|
Summary: Nextcloud Python Framework
|
|
5
5
|
Project-URL: Changelog, https://github.com/cloud-py-api/nc_py_api/blob/main/CHANGELOG.md
|
|
6
6
|
Project-URL: Documentation, https://cloud-py-api.github.io/nc_py_api/
|
|
@@ -3,35 +3,101 @@
|
|
|
3
3
|
import contextlib
|
|
4
4
|
import dataclasses
|
|
5
5
|
import typing
|
|
6
|
+
from enum import IntEnum
|
|
7
|
+
|
|
8
|
+
from pydantic import RootModel
|
|
9
|
+
from pydantic.dataclasses import dataclass
|
|
6
10
|
|
|
7
11
|
from ..._exceptions import NextcloudException, NextcloudExceptionNotFound
|
|
8
|
-
from ..._misc import
|
|
12
|
+
from ..._misc import require_capabilities
|
|
9
13
|
from ..._session import AsyncNcSessionApp, NcSessionApp
|
|
10
14
|
|
|
11
15
|
_EP_SUFFIX: str = "ai_provider/task_processing"
|
|
12
16
|
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
class ShapeType(IntEnum):
|
|
19
|
+
"""Enum for shape types."""
|
|
20
|
+
|
|
21
|
+
NUMBER = 0
|
|
22
|
+
TEXT = 1
|
|
23
|
+
IMAGE = 2
|
|
24
|
+
AUDIO = 3
|
|
25
|
+
VIDEO = 4
|
|
26
|
+
FILE = 5
|
|
27
|
+
ENUM = 6
|
|
28
|
+
LIST_OF_NUMBERS = 10
|
|
29
|
+
LIST_OF_TEXTS = 11
|
|
30
|
+
LIST_OF_IMAGES = 12
|
|
31
|
+
LIST_OF_AUDIOS = 13
|
|
32
|
+
LIST_OF_VIDEOS = 14
|
|
33
|
+
LIST_OF_FILES = 15
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class ShapeEnumValue:
|
|
38
|
+
"""Data object for input output shape enum slot value."""
|
|
39
|
+
|
|
40
|
+
name: str
|
|
41
|
+
"""Name of the enum slot value which will be displayed in the UI"""
|
|
42
|
+
value: str
|
|
43
|
+
"""Value of the enum slot value"""
|
|
44
|
+
|
|
17
45
|
|
|
18
|
-
|
|
19
|
-
|
|
46
|
+
@dataclass
|
|
47
|
+
class ShapeDescriptor:
|
|
48
|
+
"""Data object for input output shape entries."""
|
|
20
49
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
50
|
+
name: str
|
|
51
|
+
"""Name of the shape entry"""
|
|
52
|
+
description: str
|
|
53
|
+
"""Description of the shape entry"""
|
|
54
|
+
shape_type: ShapeType
|
|
55
|
+
"""Type of the shape entry"""
|
|
25
56
|
|
|
26
|
-
@property
|
|
27
|
-
def display_name(self) -> str:
|
|
28
|
-
"""Providers display name."""
|
|
29
|
-
return self._raw_data["display_name"]
|
|
30
57
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
58
|
+
@dataclass
|
|
59
|
+
class TaskType:
|
|
60
|
+
"""TaskType description for the provider."""
|
|
61
|
+
|
|
62
|
+
id: str
|
|
63
|
+
"""The unique ID for the task type."""
|
|
64
|
+
name: str
|
|
65
|
+
"""The localized name of the task type."""
|
|
66
|
+
description: str
|
|
67
|
+
"""The localized description of the task type."""
|
|
68
|
+
input_shape: list[ShapeDescriptor]
|
|
69
|
+
"""The input shape of the task."""
|
|
70
|
+
output_shape: list[ShapeDescriptor]
|
|
71
|
+
"""The output shape of the task."""
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@dataclass
|
|
75
|
+
class TaskProcessingProvider:
|
|
76
|
+
|
|
77
|
+
id: str
|
|
78
|
+
"""Unique ID for the provider."""
|
|
79
|
+
name: str
|
|
80
|
+
"""The localized name of this provider"""
|
|
81
|
+
task_type: str
|
|
82
|
+
"""The TaskType provided by this provider."""
|
|
83
|
+
expected_runtime: int = dataclasses.field(default=0)
|
|
84
|
+
"""Expected runtime of the task in seconds."""
|
|
85
|
+
optional_input_shape: list[ShapeDescriptor] = dataclasses.field(default_factory=list)
|
|
86
|
+
"""Optional input shape of the task."""
|
|
87
|
+
optional_output_shape: list[ShapeDescriptor] = dataclasses.field(default_factory=list)
|
|
88
|
+
"""Optional output shape of the task."""
|
|
89
|
+
input_shape_enum_values: dict[str, list[ShapeEnumValue]] = dataclasses.field(default_factory=dict)
|
|
90
|
+
"""The option dict for each input shape ENUM slot."""
|
|
91
|
+
input_shape_defaults: dict[str, str | int | float] = dataclasses.field(default_factory=dict)
|
|
92
|
+
"""The default values for input shape slots."""
|
|
93
|
+
optional_input_shape_enum_values: dict[str, list[ShapeEnumValue]] = dataclasses.field(default_factory=dict)
|
|
94
|
+
"""The option list for each optional input shape ENUM slot."""
|
|
95
|
+
optional_input_shape_defaults: dict[str, str | int | float] = dataclasses.field(default_factory=dict)
|
|
96
|
+
"""The default values for optional input shape slots."""
|
|
97
|
+
output_shape_enum_values: dict[str, list[ShapeEnumValue]] = dataclasses.field(default_factory=dict)
|
|
98
|
+
"""The option list for each output shape ENUM slot."""
|
|
99
|
+
optional_output_shape_enum_values: dict[str, list[ShapeEnumValue]] = dataclasses.field(default_factory=dict)
|
|
100
|
+
"""The option list for each optional output shape ENUM slot."""
|
|
35
101
|
|
|
36
102
|
def __repr__(self):
|
|
37
103
|
return f"<{self.__class__.__name__} name={self.name}, type={self.task_type}>"
|
|
@@ -44,17 +110,16 @@ class _TaskProcessingProviderAPI:
|
|
|
44
110
|
self._session = session
|
|
45
111
|
|
|
46
112
|
def register(
|
|
47
|
-
self,
|
|
113
|
+
self,
|
|
114
|
+
provider: TaskProcessingProvider,
|
|
115
|
+
custom_task_type: TaskType | None = None,
|
|
48
116
|
) -> None:
|
|
49
117
|
"""Registers or edit the TaskProcessing provider."""
|
|
50
118
|
require_capabilities("app_api", self._session.capabilities)
|
|
51
119
|
params = {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"taskType": task_type,
|
|
55
|
-
"customTaskType": custom_task_type,
|
|
120
|
+
"provider": RootModel(provider).model_dump(),
|
|
121
|
+
**({"customTaskType": RootModel(custom_task_type).model_dump()} if custom_task_type else {}),
|
|
56
122
|
}
|
|
57
|
-
clear_from_params_empty(["customTaskType"], params)
|
|
58
123
|
self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
59
124
|
|
|
60
125
|
def unregister(self, name: str, not_fail=True) -> None:
|
|
@@ -123,17 +188,16 @@ class _AsyncTaskProcessingProviderAPI:
|
|
|
123
188
|
self._session = session
|
|
124
189
|
|
|
125
190
|
async def register(
|
|
126
|
-
self,
|
|
191
|
+
self,
|
|
192
|
+
provider: TaskProcessingProvider,
|
|
193
|
+
custom_task_type: TaskType | None = None,
|
|
127
194
|
) -> None:
|
|
128
195
|
"""Registers or edit the TaskProcessing provider."""
|
|
129
196
|
require_capabilities("app_api", await self._session.capabilities)
|
|
130
197
|
params = {
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"taskType": task_type,
|
|
134
|
-
"customTaskType": custom_task_type,
|
|
198
|
+
"provider": RootModel(provider).model_dump(),
|
|
199
|
+
**({"customTaskType": RootModel(custom_task_type).model_dump()} if custom_task_type else {}),
|
|
135
200
|
}
|
|
136
|
-
clear_from_params_empty(["customTaskType"], params)
|
|
137
201
|
await self._session.ocs("POST", f"{self._session.ae_url}/{_EP_SUFFIX}", json=params)
|
|
138
202
|
|
|
139
203
|
async def unregister(self, name: str, not_fail=True) -> None:
|
|
@@ -129,6 +129,7 @@ lint.select = [
|
|
|
129
129
|
"W",
|
|
130
130
|
]
|
|
131
131
|
lint.extend-ignore = [
|
|
132
|
+
"D101",
|
|
132
133
|
"D105",
|
|
133
134
|
"D107",
|
|
134
135
|
"D203",
|
|
@@ -173,7 +174,6 @@ master.py-version = "3.10"
|
|
|
173
174
|
master.extension-pkg-allow-list = [
|
|
174
175
|
"pydantic",
|
|
175
176
|
]
|
|
176
|
-
design.max-attributes = 8
|
|
177
177
|
design.max-locals = 20
|
|
178
178
|
design.max-branches = 16
|
|
179
179
|
design.max-returns = 8
|
|
@@ -206,6 +206,7 @@ messages_control.disable = [
|
|
|
206
206
|
"line-too-long",
|
|
207
207
|
"too-few-public-methods",
|
|
208
208
|
"too-many-public-methods",
|
|
209
|
+
"too-many-instance-attributes",
|
|
209
210
|
]
|
|
210
211
|
|
|
211
212
|
[tool.pytest.ini_options]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|