isahitlab 0.0.1__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.
Files changed (82) hide show
  1. isahitlab-0.0.1/.gitignore +76 -0
  2. isahitlab-0.0.1/LICENSE.txt +9 -0
  3. isahitlab-0.0.1/PKG-INFO +45 -0
  4. isahitlab-0.0.1/README.md +22 -0
  5. isahitlab-0.0.1/docs/assets/favicon.ico +0 -0
  6. isahitlab-0.0.1/docs/dataset.md +3 -0
  7. isahitlab-0.0.1/docs/index.md +51 -0
  8. isahitlab-0.0.1/docs/project_configuration.md +3 -0
  9. isahitlab-0.0.1/docs/stylesheets/extra.css +20 -0
  10. isahitlab-0.0.1/docs/task.md +3 -0
  11. isahitlab-0.0.1/mkdocs.yml +42 -0
  12. isahitlab-0.0.1/pyproject.toml +87 -0
  13. isahitlab-0.0.1/src/isahitlab/__about__.py +4 -0
  14. isahitlab-0.0.1/src/isahitlab/__init__.py +3 -0
  15. isahitlab-0.0.1/src/isahitlab/actions/__init__.py +3 -0
  16. isahitlab-0.0.1/src/isahitlab/actions/base.py +11 -0
  17. isahitlab-0.0.1/src/isahitlab/actions/dataset.py +78 -0
  18. isahitlab-0.0.1/src/isahitlab/actions/project_configuration.py +34 -0
  19. isahitlab-0.0.1/src/isahitlab/actions/task.py +140 -0
  20. isahitlab-0.0.1/src/isahitlab/api/__init__.py +0 -0
  21. isahitlab-0.0.1/src/isahitlab/api/base.py +12 -0
  22. isahitlab-0.0.1/src/isahitlab/api/batch/__init__.py +0 -0
  23. isahitlab-0.0.1/src/isahitlab/api/batch/api.py +16 -0
  24. isahitlab-0.0.1/src/isahitlab/api/data/__init__.py +0 -0
  25. isahitlab-0.0.1/src/isahitlab/api/data/api.py +27 -0
  26. isahitlab-0.0.1/src/isahitlab/api/dataset/__init__.py +0 -0
  27. isahitlab-0.0.1/src/isahitlab/api/dataset/api.py +18 -0
  28. isahitlab-0.0.1/src/isahitlab/api/file/__init__.py +0 -0
  29. isahitlab-0.0.1/src/isahitlab/api/file/api.py +27 -0
  30. isahitlab-0.0.1/src/isahitlab/api/helpers.py +52 -0
  31. isahitlab-0.0.1/src/isahitlab/api/project/__init__.py +0 -0
  32. isahitlab-0.0.1/src/isahitlab/api/project/api.py +48 -0
  33. isahitlab-0.0.1/src/isahitlab/api/project/mappers.py +23 -0
  34. isahitlab-0.0.1/src/isahitlab/api/project_configuration/__init__.py +0 -0
  35. isahitlab-0.0.1/src/isahitlab/api/project_configuration/api.py +16 -0
  36. isahitlab-0.0.1/src/isahitlab/api/task/__init__.py +0 -0
  37. isahitlab-0.0.1/src/isahitlab/api/task/api.py +93 -0
  38. isahitlab-0.0.1/src/isahitlab/api/task/mappers.py +70 -0
  39. isahitlab-0.0.1/src/isahitlab/client.py +60 -0
  40. isahitlab-0.0.1/src/isahitlab/core/__init__.py +0 -0
  41. isahitlab-0.0.1/src/isahitlab/core/constants.py +3 -0
  42. isahitlab-0.0.1/src/isahitlab/core/http/__init__.py +0 -0
  43. isahitlab-0.0.1/src/isahitlab/core/http/auth.py +10 -0
  44. isahitlab-0.0.1/src/isahitlab/core/http/http_client.py +114 -0
  45. isahitlab-0.0.1/src/isahitlab/domain/__init__.py +0 -0
  46. isahitlab-0.0.1/src/isahitlab/domain/batch.py +3 -0
  47. isahitlab-0.0.1/src/isahitlab/domain/dataset.py +24 -0
  48. isahitlab-0.0.1/src/isahitlab/domain/pagination.py +13 -0
  49. isahitlab-0.0.1/src/isahitlab/domain/project.py +19 -0
  50. isahitlab-0.0.1/src/isahitlab/domain/task.py +57 -0
  51. isahitlab-0.0.1/src/isahitlab/exceptions.py +35 -0
  52. isahitlab-0.0.1/src/isahitlab/formatters/__init__.py +15 -0
  53. isahitlab-0.0.1/src/isahitlab/formatters/base.py +10 -0
  54. isahitlab-0.0.1/src/isahitlab/formatters/kili_to_lab_formatter.py +115 -0
  55. isahitlab-0.0.1/src/isahitlab/formatters/lab_to_kili_formatter.py +275 -0
  56. isahitlab-0.0.1/src/isahitlab/helpers/__init__.py +0 -0
  57. isahitlab-0.0.1/src/isahitlab/helpers/inputs_layout.py +15 -0
  58. isahitlab-0.0.1/src/isahitlab/helpers/labels.py +79 -0
  59. isahitlab-0.0.1/src/isahitlab/helpers/list.py +24 -0
  60. isahitlab-0.0.1/src/isahitlab/helpers/points.py +78 -0
  61. isahitlab-0.0.1/src/isahitlab/helpers/resource.py +21 -0
  62. isahitlab-0.0.1/src/isahitlab/log.py +13 -0
  63. isahitlab-0.0.1/src/isahitlab/operations/__init__.py +0 -0
  64. isahitlab-0.0.1/src/isahitlab/operations/base.py +11 -0
  65. isahitlab-0.0.1/src/isahitlab/operations/batch/__init__.py +0 -0
  66. isahitlab-0.0.1/src/isahitlab/operations/batch/get_batch.py +33 -0
  67. isahitlab-0.0.1/src/isahitlab/operations/dataset/__init__.py +0 -0
  68. isahitlab-0.0.1/src/isahitlab/operations/dataset/append_to_dataset.py +61 -0
  69. isahitlab-0.0.1/src/isahitlab/operations/project/__init__.py +0 -0
  70. isahitlab-0.0.1/src/isahitlab/operations/project/get_projects.py +35 -0
  71. isahitlab-0.0.1/src/isahitlab/operations/project_configuration/__init__.py +0 -0
  72. isahitlab-0.0.1/src/isahitlab/operations/project_configuration/get_project_configuration.py +32 -0
  73. isahitlab-0.0.1/src/isahitlab/operations/task/__init__.py +0 -0
  74. isahitlab-0.0.1/src/isahitlab/operations/task/create_tasks.py +179 -0
  75. isahitlab-0.0.1/src/isahitlab/operations/task/get_tasks.py +56 -0
  76. isahitlab-0.0.1/src/isahitlab/validators/__init__.py +45 -0
  77. isahitlab-0.0.1/src/isahitlab/validators/form_validation_builder.py +67 -0
  78. isahitlab-0.0.1/src/isahitlab/validators/validation_schemas/__init__.py +11 -0
  79. isahitlab-0.0.1/src/isahitlab/validators/validation_schemas/kili_schema.py +151 -0
  80. isahitlab-0.0.1/src/isahitlab/validators/validation_schemas/lab_iat_rectangle_schema.py +10 -0
  81. isahitlab-0.0.1/src/isahitlab/validators/validation_schemas/lab_iat_schema.py +94 -0
  82. isahitlab-0.0.1/src/isahitlab/validators/validation_schemas/lab_iat_segmentation_schema.py +20 -0
@@ -0,0 +1,76 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+
3
+ # compiled output
4
+ /dist
5
+ /dist-test
6
+ /dist-dev
7
+ /tmp
8
+ /out-tsc
9
+
10
+
11
+ # dependencies
12
+ /node_modules
13
+ **/node_modules
14
+ **/web_modules
15
+
16
+ # IDEs and editors
17
+ /.idea
18
+ .project
19
+ .classpath
20
+ .c9/
21
+ *.launch
22
+ .settings/
23
+ *.sublime-workspace
24
+
25
+ # IDE - VSCode
26
+ .vscode/*
27
+ !.vscode/settings.json
28
+ !.vscode/tasks.json
29
+ !.vscode/launch.json
30
+ !.vscode/extensions.json
31
+
32
+ # misc
33
+ /.angular/cache
34
+ /.sass-cache
35
+ /connect.lock
36
+ /coverage
37
+ /libpeerconnection.log
38
+ npm-debug.log
39
+ yarn-error.log
40
+ testem.log
41
+ /typings
42
+
43
+ # System Files
44
+ .DS_Store
45
+ Thumbs.db
46
+
47
+ #Credentials
48
+ *.key
49
+
50
+ #Ignore .env.*
51
+ .env.*
52
+
53
+ docker-compose.env
54
+ tools/keycloak/deployments/*.deployed
55
+ tools/keycloak/deployments/*.isdeploying
56
+ /release-config
57
+ /.angular
58
+
59
+ .angular
60
+ tools/kafka/dist/
61
+ tools/kafka/dist
62
+
63
+ shared-temp/*
64
+
65
+ cerbos/policies
66
+ **/__pycache__
67
+
68
+ **/secrets/*shared-temp/
69
+ .nx
70
+ sdk/lab/lab-sdk-env/
71
+ sdk/lab/tests/veolia_kili/
72
+ lab-sdk-env/
73
+ envs
74
+ sdk/output/
75
+ sdk/lab/site/
76
+ sdk/lab/dist/
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present Benjamin Piogé <benjamin@isahit.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.3
2
+ Name: isahitlab
3
+ Version: 0.0.1
4
+ Summary: Python client for isahit lab
5
+ Project-URL: Documentation, https://sdk-docs.lab.isahit.com/latest/
6
+ Author-email: Isahit <dev@isahit.com>
7
+ License: MIT
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Programming Language :: Python
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: Implementation :: CPython
16
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
17
+ Requires-Python: >=3.8
18
+ Requires-Dist: jsonschema>=4
19
+ Requires-Dist: requests<3.0.0,>=2.0.0
20
+ Requires-Dist: tqdm<5.0.0,>=4.0.0
21
+ Requires-Dist: typeguard<5,>=4
22
+ Description-Content-Type: text/markdown
23
+
24
+ # isahitlab
25
+
26
+ [![PyPI - Version](https://img.shields.io/pypi/v/isahitlab.svg)](https://pypi.org/project/isahitlab)
27
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/isahitlab.svg)](https://pypi.org/project/isahitlab)
28
+
29
+ -----
30
+
31
+ ## Table of Contents
32
+
33
+ - [Installation](#installation)
34
+ - [License](#license)
35
+
36
+ ## Installation
37
+
38
+ ```console
39
+ pip install isahitlab
40
+ ```
41
+
42
+
43
+ ## License
44
+
45
+ `isahitlab` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,22 @@
1
+ # isahitlab
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/isahitlab.svg)](https://pypi.org/project/isahitlab)
4
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/isahitlab.svg)](https://pypi.org/project/isahitlab)
5
+
6
+ -----
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [License](#license)
12
+
13
+ ## Installation
14
+
15
+ ```console
16
+ pip install isahitlab
17
+ ```
18
+
19
+
20
+ ## License
21
+
22
+ `isahitlab` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
Binary file
@@ -0,0 +1,3 @@
1
+ # Dataset module
2
+
3
+ ::: isahitlab.actions.dataset
@@ -0,0 +1,51 @@
1
+ # Getting started
2
+
3
+ This is the documentation of the Python SDK for [Isahit Lab](https://lab.isahit.com).
4
+
5
+ Learn more about **isahit** [here](https://www.isahit.com).
6
+
7
+ ## Installation
8
+
9
+ Install the client
10
+
11
+ ```bash { .copy }
12
+ pip install isahitlab
13
+ ```
14
+
15
+ ## Basic usage
16
+
17
+ * Create your credentials in your lab account
18
+ * Add the access id and the secret key to your environment variables
19
+
20
+ ```bash { .copy }
21
+ export ISAHIT_LAB_API_ACCESS_ID='<your_access_id>'
22
+ export ISAHIT_LAB_API_SECRET_KEY='<your_secret_key>'
23
+ ```
24
+
25
+ * Instanciate the client
26
+
27
+ ```python { .copy }
28
+ from isahitlab.client import IsahitLab
29
+
30
+ lab = IsahitLab()
31
+ ```
32
+
33
+
34
+ !!! info
35
+ You can also pass the API key as an argument during `Kili` initialization:
36
+
37
+ ```python { .copy }
38
+ from isahitlab.client import IsahitLab
39
+
40
+ lab = IsahitLab(
41
+ access_id="<your_access_id>",
42
+ secret_key="<your_secret_key>",
43
+ )
44
+
45
+ ```
46
+
47
+ !!! success "Try it!"
48
+ ```python { .copy }
49
+ lab.project_configuration(project_id=<your_project_id>)
50
+
51
+ ```
@@ -0,0 +1,3 @@
1
+ # Project configuration module
2
+
3
+ ::: isahitlab.actions.project_configuration
@@ -0,0 +1,20 @@
1
+ [data-md-color-scheme="isahit"] {
2
+ --md-primary-fg-color: #FF534A;
3
+ --md-primary-fg-color--light: #ECB7B7;
4
+ --md-primary-fg-color--dark: #90030C;
5
+ --md-default-bg-color: #f8f5f1;
6
+ --md-code-bg-color: #e7e7e7;
7
+ }
8
+
9
+ .md-header__topic .md-ellipsis{
10
+ line-height: 2.9;
11
+ }
12
+
13
+ .md-header__topic{
14
+ margin-left: 50px;
15
+
16
+ }
17
+
18
+ .md-typeset{
19
+ font-size: 12pt;
20
+ }
@@ -0,0 +1,3 @@
1
+ # Task module
2
+
3
+ ::: isahitlab.actions.task
@@ -0,0 +1,42 @@
1
+ site_name: Lab Python SDK
2
+ site_url: 'http://localhost:8000/'
3
+ nav:
4
+ - Getting started: index.md
5
+ # - Installation: installation.md
6
+ - Code Reference:
7
+ - Task: task.md
8
+ - Dataset: dataset.md
9
+ - Project Configuration: project_configuration.md
10
+
11
+ theme:
12
+ name: "material"
13
+ logo: https://isahit-public.s3.eu-west-3.amazonaws.com/saas/isahit-logo-fond-fonce.png
14
+ favicon: assets/favicon.ico
15
+ features:
16
+ - content.code.copy
17
+ palette:
18
+ scheme: isahit
19
+
20
+ extra_css:
21
+ - stylesheets/extra.css
22
+
23
+ plugins:
24
+ - search
25
+ - mkdocstrings
26
+ - mike:
27
+ version_selector: true
28
+
29
+ extra:
30
+ version:
31
+ provider: mike
32
+
33
+ markdown_extensions:
34
+ - admonition
35
+ - pymdownx.details
36
+ - pymdownx.highlight:
37
+ anchor_linenums: true
38
+ line_spans: __span
39
+ pygments_lang_class: true
40
+ - pymdownx.inlinehilite
41
+ - pymdownx.snippets
42
+ - pymdownx.superfences
@@ -0,0 +1,87 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "isahitlab"
7
+ dynamic = ["version"]
8
+ description = 'Python client for isahit lab'
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = "MIT"
12
+ keywords = []
13
+ authors = [
14
+ { name = "Isahit", email = "dev@isahit.com" },
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: Implementation :: CPython",
25
+ "Programming Language :: Python :: Implementation :: PyPy",
26
+ ]
27
+ dependencies = [
28
+ "requests >= 2.0.0, < 3.0.0",
29
+ "tqdm >= 4.0.0, < 5.0.0",
30
+ "typeguard >= 4, < 5",
31
+ "jsonschema >= 4"
32
+ ]
33
+
34
+
35
+ [tool.hatch.envs.docs]
36
+ dependencies = [
37
+ "mkdocs",
38
+ "mkdocstrings[python]",
39
+ "mkdocs-material",
40
+ "mkdocstrings",
41
+ "mike"
42
+ ]
43
+ [tool.hatch.envs.docs.scripts]
44
+ build = "mkdocs build --clean --strict"
45
+ serve = "mkdocs serve --dev-addr localhost:8000"
46
+
47
+ [project.urls]
48
+ Documentation = "https://sdk-docs.lab.isahit.com/latest/"
49
+
50
+
51
+ [tool.hatch.version]
52
+ path = "src/isahitlab/__about__.py"
53
+
54
+ [tool.hatch.envs.types]
55
+ dependencies = [
56
+ "python-dateutil >= 2.0.0"
57
+ ]
58
+ extra-dependencies = [
59
+ "mypy>=1.0.0"
60
+ ]
61
+ [tool.hatch.envs.types.scripts]
62
+ check = "mypy --install-types --non-interactive {args:src/isahitlab tests}"
63
+
64
+ [tool.coverage.run]
65
+ source_pkgs = ["isahitlab", "tests"]
66
+ branch = true
67
+ parallel = true
68
+ omit = [
69
+ "src/isahitlab/__about__.py",
70
+ ]
71
+
72
+ [tool.coverage.paths]
73
+ isahitlab = ["src/isahitlab", "*/lab/src/isahitlab"]
74
+ tests = ["tests", "*/lab/tests"]
75
+
76
+ [tool.coverage.report]
77
+ exclude_lines = [
78
+ "no cov",
79
+ "if __name__ == .__main__.:",
80
+ "if TYPE_CHECKING:",
81
+ ]
82
+
83
+ [tool.hatch.build.targets.sdist]
84
+ exclude = [
85
+ "/tests",
86
+ "/site",
87
+ ]
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2024-present Benjamin Piogé <benjamin@isahit.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ __version__ = "0.0.1"
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2024-present Benjamin Piogé <benjamin@isahit.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,3 @@
1
+ """Isahit Lab Python SDK."""
2
+
3
+ __version__ = "0.0.1"
@@ -0,0 +1,11 @@
1
+ from abc import ABC
2
+ from isahitlab.core.http.http_client import HttpClient
3
+
4
+
5
+ class BaseAction(ABC):
6
+ """Base class for all actions.
7
+ It is used to share the HttpClient between all actions classes.
8
+ It is not meant to be used and instantiated directly.
9
+ """
10
+
11
+ http_client: HttpClient # instantianted in the isahitlab client child class
@@ -0,0 +1,78 @@
1
+ import warnings
2
+ from typing import List, Optional, Iterable, Dict, Union
3
+ from isahitlab.actions.base import BaseAction
4
+ from isahitlab.operations.dataset.append_to_dataset import AppendToDatasetOperation
5
+ from isahitlab.operations.batch.get_batch import GetBatchOperation
6
+ from isahitlab.domain.batch import BatchId
7
+ from isahitlab.domain.project import ProjectId
8
+ from isahitlab.domain.dataset import DatasetId, FilePayload
9
+
10
+ from typeguard import typechecked
11
+
12
+ class DatasetActions(BaseAction):
13
+ """Dataset actions"""
14
+
15
+ @typechecked
16
+ def append_to_dataset(
17
+ self,
18
+ project_id: str,
19
+ files: List[Union[Dict, str]],
20
+ batch_id: Optional[str] = None,
21
+ dataset_id: Optional[str] = None,
22
+ disable_progress_bar: Optional[bool] = False,
23
+ ) -> Iterable[Dict]:
24
+ """ Add files to a dataset
25
+
26
+ Args:
27
+ project_id: ID of the project
28
+ dataset_id: ID of the dataset_id
29
+ You can also provide a batch_id to use the dataset linked to the batch
30
+ batch_id: ID of the batch
31
+ files : list of the file to create, str or Dict -> FilePayload(path : str, file : str)
32
+ disable_progress_bar: Disable the progress bar display
33
+ """
34
+
35
+ if not dataset_id and not batch_id:
36
+ raise ValueError(
37
+ 'You must provide a dataset_id or a batch_id'
38
+ )
39
+
40
+ # Get the dataset linked to the batch
41
+ if not dataset_id:
42
+ batch = GetBatchOperation(self.http_client).run(batch_id=batch_id, disable_progress_bar=disable_progress_bar)
43
+ if not batch:
44
+ raise ValueError("Batch not found")
45
+ if batch['projectId'] != project_id:
46
+ raise ValueError("batch_id is not a batch of the project")
47
+ if not batch['dataset']:
48
+ raise ValueError('The batch has no dataset')
49
+ dataset_id = batch['dataset']['id']
50
+
51
+ if not dataset_id:
52
+ raise ValueError("Unknown dataset")
53
+
54
+ operation = AppendToDatasetOperation(self.http_client)
55
+
56
+ file_payloads = [*map(lambda t: FilePayload(
57
+ file=t['file'] if not isinstance(t, str) else t,
58
+ path=self._format_path(t['path']) if not isinstance(t, str) else None
59
+ ), files)]
60
+
61
+ return operation.run(project_id=project_id,
62
+ dataset_id=dataset_id,
63
+ files=file_payloads,
64
+ disable_progress_bar=disable_progress_bar
65
+ )
66
+
67
+ def _format_path(self, path: str) -> str:
68
+ if not path:
69
+ return None
70
+ path = path.strip().strip('/')
71
+
72
+ if len(path) == 0:
73
+ return None
74
+
75
+ return path + '/'
76
+
77
+
78
+
@@ -0,0 +1,34 @@
1
+ from tqdm import tqdm
2
+ from typing import List, Optional, Iterable, Dict, cast
3
+ from isahitlab.actions.base import BaseAction
4
+ from isahitlab.api.task.api import TaskApi
5
+ from isahitlab.api.project_configuration.api import ProjectConfigurationApi
6
+ from isahitlab.domain.task import TaskFilters, TaskStatus, TaskOptionalFields, TaskId, TaskCompatibilityMode
7
+ from isahitlab.domain.batch import BatchId
8
+ from isahitlab.operations.project_configuration.get_project_configuration import GetProjectConfigurationOperation
9
+ from isahitlab.formatters import get_compatibility_formatter
10
+
11
+ from typeguard import typechecked
12
+
13
+ class ProjectConfigurationActions(BaseAction):
14
+ """Project configuration actions"""
15
+
16
+ @typechecked
17
+ def project_configuration(
18
+ self,
19
+ project_id: str,
20
+ disable_progress_bar: Optional[bool] = False
21
+ ) -> Dict:
22
+ """ Get the configuration of a project
23
+
24
+ Args:
25
+ project_id: ID of the project
26
+ disable_progress_bar: Disable the progress bar display
27
+
28
+ """
29
+
30
+ operation = GetProjectConfigurationOperation(self.http_client)
31
+
32
+ return operation.run(project_id=project_id, disable_progress_bar=disable_progress_bar)
33
+
34
+
@@ -0,0 +1,140 @@
1
+ import warnings
2
+ from typing import List, Optional, Iterable, Dict, cast
3
+ from isahitlab.actions.base import BaseAction
4
+ from isahitlab.operations.task.get_tasks import GetTasksOperation
5
+ from isahitlab.operations.task.create_tasks import CreateTask
6
+ from isahitlab.operations.project.get_projects import GetProjectsOperation
7
+ from isahitlab.domain.task import TaskFilters, TaskStatus, TaskOptionalFields, TaskId, TaskCompatibilityMode, TaskPayload
8
+ from isahitlab.domain.batch import BatchId
9
+ from isahitlab.domain.project import ProjectId, ProjectFilters, ProjectType
10
+
11
+ from typeguard import typechecked
12
+
13
+ class TaskActions(BaseAction):
14
+ """Tasks actions"""
15
+
16
+ @typechecked
17
+ def tasks(
18
+ self,
19
+ project_id: ProjectId,
20
+ batch_ids: Optional[List[str]] = None,
21
+ status_in: Optional[List[str]] = None,
22
+ task_id_in: Optional[List[str]] = None,
23
+ name_in: Optional[List[str]] = None,
24
+ name_like: Optional[str] = None,
25
+ created_at_gt: Optional[str] = None,
26
+ created_at_gte: Optional[str] = None,
27
+ created_at_lt: Optional[str] = None,
28
+ created_at_lte: Optional[str] = None,
29
+ updated_at_gt: Optional[str] = None,
30
+ updated_at_gte: Optional[str] = None,
31
+ updated_at_lt: Optional[str] = None,
32
+ updated_at_lte: Optional[str] = None,
33
+ optional_fields: Optional[List[TaskOptionalFields]] = ["data"],
34
+ disable_progress_bar: Optional[bool] = False,
35
+ compatibility_mode: Optional[TaskCompatibilityMode] = None
36
+ ) -> Iterable[Dict]:
37
+ """ Get an task list
38
+
39
+ Args:
40
+ project_id: ID of the project
41
+ batch_ids: A list of batch ids to filter
42
+ status_in: Only in those statuses.
43
+ Possible choices: `pending`, `complete`, `configuring`.
44
+ task_id_in: Only task whose ID is in this list,
45
+ name_in: Only task whose name is in this list,
46
+ name_like: Only task whose name mathes this regex,
47
+ created_at_gt: Only tasks created after this date (Ex.: "2022-09-19 08:30:00")
48
+ created_at_gte: Only tasks created at or after this date (Ex.: "2022-09-19 08:30:00")
49
+ created_at_lt: Only tasks created before this date (Ex.: "2022-09-19 08:30:00")
50
+ created_at_lte: Only tasks created at or before this date (Ex.: "2022-09-19 08:30:00")
51
+ updated_at_gt: Only tasks updated after this date (Ex.: "2022-09-19 08:30:00")
52
+ updated_at_gte: Only tasks updated at or after this date (Ex.: "2022-09-19 08:30:00")
53
+ updated_at_lt: Only tasks updated before this date (Ex.: "2022-09-19 08:30:00")
54
+ updated_at_lte: Only tasks updated at or before this date (Ex.: "2022-09-19 08:30:00")
55
+ optional_fields: retreive those additional information
56
+ Possible choices: `data`, `jobs`, `metrics`, `data.mask`(for segmentation project).
57
+ disable_progress_bar: Disable the progress bar display
58
+ compatibility_mode: Format the output for specific use cases
59
+ Possible choices: `kili` -> format the ouput to look like kili.assets() results
60
+
61
+ """
62
+
63
+ filters = TaskFilters(
64
+ project_id=project_id,
65
+ batch_id_in = cast(List[BatchId], batch_ids) if batch_ids else None,
66
+ status_in = cast(List[TaskStatus], status_in) if status_in else None,
67
+ task_id_in = cast(List[TaskId], task_id_in) if task_id_in else None,
68
+ name_in = cast(List[str], name_in) if name_in else None,
69
+ name_like = name_like if name_like else None,
70
+ created_at_gt = cast(List[str], created_at_gt) if created_at_gt else None,
71
+ created_at_gte = cast(List[str], created_at_gte) if created_at_gte else None,
72
+ created_at_lt = cast(List[str], created_at_lt) if created_at_lt else None,
73
+ created_at_lte = cast(List[str], created_at_lte) if created_at_lte else None,
74
+ updated_at_gt = cast(List[str], updated_at_gt) if updated_at_gt else None,
75
+ updated_at_gte = cast(List[str], updated_at_gte) if updated_at_gte else None,
76
+ updated_at_lt = cast(List[str], updated_at_lt) if updated_at_lt else None,
77
+ updated_at_lte = cast(List[str], updated_at_lte) if updated_at_lte else None,
78
+ optional_fields = cast(List[TaskOptionalFields], optional_fields) if optional_fields else None
79
+ )
80
+
81
+ operation = GetTasksOperation(self.http_client)
82
+
83
+ return operation.run(project_id=project_id, filters=filters, disable_progress_bar=disable_progress_bar, compatibility_mode=compatibility_mode )
84
+
85
+
86
+ @typechecked
87
+ def create_tasks(
88
+ self,
89
+ project_id: str,
90
+ batch_id: str,
91
+ tasks: List[Dict],
92
+ disable_progress_bar: Optional[bool] = False,
93
+ disable_data_check: Optional[bool] = False,
94
+ disable_unicity_check: Optional[bool] = False,
95
+ raise_if_existing: Optional[bool] = True,
96
+ compatibility_mode: Optional[TaskCompatibilityMode] = None
97
+ ) -> Iterable[Dict]:
98
+ """ Create tasks in a batch
99
+
100
+ Args:
101
+ project_id: ID of the project
102
+ batch_id: ID of the batch project
103
+ tasks : list of the tasks to create. See TaskPayload(name : str, resource : str, data : Dict[str, Any])
104
+ disable_progress_bar: Disable the progress bar display
105
+ disable_data_check: Set this option to False to ignore the data format validation
106
+ disable_unicity_check: Set this option to True to ignore duplicate check and insert it anyway
107
+ raise_if_existing: Set this option to False to skip task duplicates and only show a warning
108
+ compatibility_mode: Format the output for specific use cases
109
+ Possible choices: `kili` -> format the ouput to look like kili.assets() results
110
+
111
+ """
112
+
113
+ projects = GetProjectsOperation(self.http_client).run(filters=ProjectFilters(id_in=[project_id]), disable_progress_bar=disable_progress_bar)
114
+ project = projects[0] if len(projects) > 0 else None
115
+
116
+ if not project:
117
+ warnings.warn('Project not found')
118
+ return
119
+
120
+ project_type : ProjectType = project['type']
121
+
122
+ operation = CreateTask(self.http_client)
123
+ task_payloads = [*map(lambda t: TaskPayload(
124
+ name=t['name'],
125
+ resources=t['resources'] if project_type != "form" else None,
126
+ data=t['data'] if 'data' in t else None
127
+ ), tasks)]
128
+
129
+ tasks = operation.run(project_id=project_id,
130
+ batch_id=batch_id,
131
+ tasks=task_payloads,
132
+ disable_progress_bar=disable_progress_bar,
133
+ disable_unicity_check=disable_unicity_check,
134
+ raise_if_existing=raise_if_existing,
135
+ disable_data_check=disable_data_check,
136
+ compatibility_mode=compatibility_mode
137
+ )
138
+
139
+ return tasks
140
+
File without changes
@@ -0,0 +1,12 @@
1
+ from abc import ABC
2
+ from isahitlab.core.http.http_client import HttpClient
3
+
4
+
5
+ class BaseApi(ABC):
6
+ """Base class for all API"""
7
+
8
+ http_client: HttpClient # instantianted in the isahitlab client child class
9
+
10
+ def __init__(self, http_client: HttpClient) -> None:
11
+ """Initialize Base Api Class."""
12
+ self._http_client = http_client
File without changes