qmenta-client 3.0.0.dev1530__tar.gz → 4.0.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.
@@ -0,0 +1,16 @@
1
+ __pycache__
2
+ *.pyc
3
+ .idea/
4
+ .vscode/
5
+ docs/_build
6
+ build/
7
+ dist/
8
+ *.user
9
+ *.autosave
10
+ .DS_Store
11
+ .pytest_cache
12
+ .coverage
13
+ build_docs/
14
+ .env
15
+ logs_1.txt
16
+ .venv/
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.5
2
+ Name: qmenta-client
3
+ Version: 4.0.0
4
+ Summary: Python client lib to interact with the QMENTA platform.
5
+ Project-URL: Homepage, https://www.qmenta.com/
6
+ Project-URL: Documentation, https://docs.qmenta.com/client/
7
+ Author-email: QMENTA <dev@qmenta.com>
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Requires-Python: <4,>=3.10
17
+ Requires-Dist: qmenta-core<7,>=6.0.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ # QMENTA client library
21
+ This library allows interaction with the QMENTA platform.
22
+ It works with Python 2 and 3. We recommend using Python 3.
23
+ Check the [tutorial](https://docs.qmenta.com/client/tutorial.html) and
24
+ [docs](https://docs.qmenta.com/client/index.html).
25
+
26
+ ## Installation
27
+ If you do not have PIP installed, on Ubuntu/Debian, it can be installed by:
28
+
29
+ ```bash
30
+ sudo apt-get install python3-pip
31
+ ```
32
+
33
+ Install QMENTA client lib using PIP:
34
+
35
+ ```bash
36
+ pip install qmenta-client
37
+ ```
38
+
39
+ ## Development
40
+ ### How to install dependencies on MacOS
41
+ Download and install Python 3.10 from https://www.python.org/downloads/
42
+
43
+ Install Xcode Command Line Tools:
44
+
45
+ ```bash
46
+ xcode-select --install
47
+ ```
48
+
49
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/), then
50
+ install the Python dependencies of QMENTA client library:
51
+
52
+ ```bash
53
+ cd mintapi/
54
+ uv sync
55
+ ```
56
+
57
+ Run the unit tests and build the docs:
58
+
59
+ ```bash
60
+ uv run pytest test/unittesting
61
+ uv run sphinx-build -W doc build/docs
62
+ ```
63
+
64
+ The docs need Python 3.10–3.12 (Sphinx 5 does not support Python 3.13). If
65
+ your default Python is newer, prefix the commands with `UV_PYTHON=3.12`.
66
+
67
+ ## Install pre-commit hook: Formatting and linting
68
+
69
+ This hook formats the Python code with [Black](https://github.com/psf/black) and checks for linting
70
+ errors with [flake8](https://flake8.pycqa.org/en/latest/). If one of the tools fails, the code will be
71
+ left formatted but there won't be a commit, so you will have potentially fix the linting errors and then stage and
72
+ commit the formatted files.
73
+
74
+ In order to install this hook, first install the following Python library in your Python environment:
75
+
76
+ ```bash
77
+ pip install pre-commit
78
+ ```
79
+
80
+ Then run the following command to install the pre-commit hook:
81
+
82
+ ```bash
83
+ pre-commit
84
+ pre-commit install
85
+ pre-commit autoupdate
86
+ ```
87
+
88
+ Check that it executes properly by running:
89
+
90
+ ```bash
91
+ pre-commit run --all-files
92
+ ```
93
+
94
+ A more in-depth explanation of the `pre-commit` utility can be found [here](https://pre-commit.com/#quick-start).
95
+
96
+ ## Install commit-msg hook: JIRA issue in commit message
97
+
98
+ This hook inserts a prefix with the JIRA issue identifier, so that
99
+ commits are linked to their issue. It runs after your commit message is written, and the JIRA issue identifier is
100
+ extracted from the branch name.
101
+
102
+ For example, if you are working in issue NEURO-1234, and you write a commit message like the following:
103
+ "Updated requirements", the final commit message will be "NEURO-1234 - Updated requirements"
104
+
105
+ In order to install this hook, open a terminal in your local copy of the repository and run the following commands:
106
+
107
+ ```bash
108
+ wget -q -O .git/hooks/commit-msg https://bit.ly/2SZ5WJO
109
+ chmod 777 .git/hooks/commit-msg
110
+ ```
111
+
112
+ ### Unit Tests
113
+ Run tests using script file
114
+
115
+ ```bash
116
+ scripts/run_unit_tests.sh
117
+ ```
118
+ ### API Tests
119
+ Warning: needs the `.env` file with the following configuration and credentials
120
+ `QMENTA_PLATFORM_LOCATION=https://platform.qmenta.com`,
121
+ `QMENTA_PLATFORM_USR` from `qmenta_tools` project secret "prod_user" and
122
+ `QMENTA_PLATFORM_PSW` from `qmenta_tools` project secret "prod_password"
123
+
124
+
125
+ Run tests using script file
126
+
127
+ ```bash
128
+ scripts/run_API_tests.sh
129
+ ```
130
+
131
+ ### Keep track of changes
132
+
133
+ Check the CONTRIBUTING.md file to see how to use scriv and keep track of the changes
134
+
135
+ ### Release in master
136
+
137
+ Update your local branches
138
+
139
+ ```bash
140
+ git checkout develop && git pull
141
+ git checkout master && git pull
142
+ ```
143
+
144
+ Create a new branch for releasing (X.Y.z is the version to release)
145
+
146
+ ```bash
147
+ git checkout -b release-X.Y.z
148
+ git merge develop
149
+ scriv collect # update changelog
150
+ git push --set-upstream origin release-X.Y.z
151
+ ```
152
+
153
+ Make and commit other changes, such as updating changelog
154
+
155
+ ```bash
156
+ git commit -am "Update repository code for release"
157
+ git push
158
+ ```
159
+
160
+ Create a Pull Request, wait for approvals and merge the release branch to master.
161
+
162
+ After release, merge the changes in master to develop
163
+
164
+ ```bash
165
+ git checkout develop && git pull && git merge master
166
+ ```
@@ -0,0 +1,147 @@
1
+ # QMENTA client library
2
+ This library allows interaction with the QMENTA platform.
3
+ It works with Python 2 and 3. We recommend using Python 3.
4
+ Check the [tutorial](https://docs.qmenta.com/client/tutorial.html) and
5
+ [docs](https://docs.qmenta.com/client/index.html).
6
+
7
+ ## Installation
8
+ If you do not have PIP installed, on Ubuntu/Debian, it can be installed by:
9
+
10
+ ```bash
11
+ sudo apt-get install python3-pip
12
+ ```
13
+
14
+ Install QMENTA client lib using PIP:
15
+
16
+ ```bash
17
+ pip install qmenta-client
18
+ ```
19
+
20
+ ## Development
21
+ ### How to install dependencies on MacOS
22
+ Download and install Python 3.10 from https://www.python.org/downloads/
23
+
24
+ Install Xcode Command Line Tools:
25
+
26
+ ```bash
27
+ xcode-select --install
28
+ ```
29
+
30
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/), then
31
+ install the Python dependencies of QMENTA client library:
32
+
33
+ ```bash
34
+ cd mintapi/
35
+ uv sync
36
+ ```
37
+
38
+ Run the unit tests and build the docs:
39
+
40
+ ```bash
41
+ uv run pytest test/unittesting
42
+ uv run sphinx-build -W doc build/docs
43
+ ```
44
+
45
+ The docs need Python 3.10–3.12 (Sphinx 5 does not support Python 3.13). If
46
+ your default Python is newer, prefix the commands with `UV_PYTHON=3.12`.
47
+
48
+ ## Install pre-commit hook: Formatting and linting
49
+
50
+ This hook formats the Python code with [Black](https://github.com/psf/black) and checks for linting
51
+ errors with [flake8](https://flake8.pycqa.org/en/latest/). If one of the tools fails, the code will be
52
+ left formatted but there won't be a commit, so you will have potentially fix the linting errors and then stage and
53
+ commit the formatted files.
54
+
55
+ In order to install this hook, first install the following Python library in your Python environment:
56
+
57
+ ```bash
58
+ pip install pre-commit
59
+ ```
60
+
61
+ Then run the following command to install the pre-commit hook:
62
+
63
+ ```bash
64
+ pre-commit
65
+ pre-commit install
66
+ pre-commit autoupdate
67
+ ```
68
+
69
+ Check that it executes properly by running:
70
+
71
+ ```bash
72
+ pre-commit run --all-files
73
+ ```
74
+
75
+ A more in-depth explanation of the `pre-commit` utility can be found [here](https://pre-commit.com/#quick-start).
76
+
77
+ ## Install commit-msg hook: JIRA issue in commit message
78
+
79
+ This hook inserts a prefix with the JIRA issue identifier, so that
80
+ commits are linked to their issue. It runs after your commit message is written, and the JIRA issue identifier is
81
+ extracted from the branch name.
82
+
83
+ For example, if you are working in issue NEURO-1234, and you write a commit message like the following:
84
+ "Updated requirements", the final commit message will be "NEURO-1234 - Updated requirements"
85
+
86
+ In order to install this hook, open a terminal in your local copy of the repository and run the following commands:
87
+
88
+ ```bash
89
+ wget -q -O .git/hooks/commit-msg https://bit.ly/2SZ5WJO
90
+ chmod 777 .git/hooks/commit-msg
91
+ ```
92
+
93
+ ### Unit Tests
94
+ Run tests using script file
95
+
96
+ ```bash
97
+ scripts/run_unit_tests.sh
98
+ ```
99
+ ### API Tests
100
+ Warning: needs the `.env` file with the following configuration and credentials
101
+ `QMENTA_PLATFORM_LOCATION=https://platform.qmenta.com`,
102
+ `QMENTA_PLATFORM_USR` from `qmenta_tools` project secret "prod_user" and
103
+ `QMENTA_PLATFORM_PSW` from `qmenta_tools` project secret "prod_password"
104
+
105
+
106
+ Run tests using script file
107
+
108
+ ```bash
109
+ scripts/run_API_tests.sh
110
+ ```
111
+
112
+ ### Keep track of changes
113
+
114
+ Check the CONTRIBUTING.md file to see how to use scriv and keep track of the changes
115
+
116
+ ### Release in master
117
+
118
+ Update your local branches
119
+
120
+ ```bash
121
+ git checkout develop && git pull
122
+ git checkout master && git pull
123
+ ```
124
+
125
+ Create a new branch for releasing (X.Y.z is the version to release)
126
+
127
+ ```bash
128
+ git checkout -b release-X.Y.z
129
+ git merge develop
130
+ scriv collect # update changelog
131
+ git push --set-upstream origin release-X.Y.z
132
+ ```
133
+
134
+ Make and commit other changes, such as updating changelog
135
+
136
+ ```bash
137
+ git commit -am "Update repository code for release"
138
+ git push
139
+ ```
140
+
141
+ Create a Pull Request, wait for approvals and merge the release branch to master.
142
+
143
+ After release, merge the changes in master to develop
144
+
145
+ ```bash
146
+ git checkout develop && git pull && git merge master
147
+ ```
@@ -0,0 +1,61 @@
1
+ [project]
2
+ name = "qmenta-client"
3
+ version = "4.0.0"
4
+ description = "Python client lib to interact with the QMENTA platform."
5
+ authors = [{ name = "QMENTA", email = "dev@qmenta.com" }]
6
+ requires-python = ">=3.10,<4"
7
+ readme = "README.md"
8
+ classifiers = [
9
+ "Development Status :: 4 - Beta",
10
+ "Intended Audience :: Developers",
11
+ "Programming Language :: Python :: 3",
12
+ "Programming Language :: Python :: 3.10",
13
+ "Programming Language :: Python :: 3.11",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Programming Language :: Python :: 3.13",
16
+ "Programming Language :: Python :: 3.14",
17
+ ]
18
+ dependencies = [
19
+ "qmenta-core>=6.0.0,<7",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://www.qmenta.com/"
24
+ Documentation = "https://docs.qmenta.com/client/"
25
+
26
+ [dependency-groups]
27
+ dev = [
28
+ "pytest>=7.1.2,<8",
29
+ "pytest-cov>=6.1.1,<7",
30
+ "sphinx>=5.0,<6",
31
+ "sphinx-rtd-theme>=1.0.0,<2",
32
+ "dom-toml>=0.6.0,<0.7",
33
+ "scriv[toml]>=0.15.2,<0.16",
34
+ "coverage>=7.2.5,<8",
35
+ "flake8>=7.1.2,<8",
36
+ "responses>=0.25.7,<0.26",
37
+ ]
38
+
39
+ [tool.hatch.build.targets.sdist]
40
+ include = ["src/qmenta"]
41
+
42
+ [tool.hatch.build.targets.wheel]
43
+ packages = ["src/qmenta"]
44
+
45
+ [build-system]
46
+ requires = ["hatchling>=1.27,<2"]
47
+ build-backend = "hatchling.build"
48
+
49
+ [tool.scriv]
50
+ format = "md"
51
+ md_header_level = "2"
52
+ insert_marker = "scriv-insert-here"
53
+ version = "literal: pyproject.toml: project.version"
54
+ entry_title_template = "[{{ version }}] - {{ date.strftime('%Y-%m-%d') }}"
55
+
56
+ [tool.uv]
57
+ # Same uv as the Cloud Build image -- bump them together.
58
+ required-version = "==0.11.17"
59
+ exclude-newer = "7 days"
60
+ # First-party packages, released by our own pipelines: no cooldown.
61
+ exclude-newer-package = { qmenta-core = false, qmenta-anon = false }
@@ -3,7 +3,7 @@ from __future__ import print_function
3
3
  import logging
4
4
  from qmenta.core import errors
5
5
  from qmenta.core import platform
6
- from qmenta.core.auth import InvalidLoginError
6
+ from qmenta.core.auth import InvalidLoginError, Needs2FAError
7
7
  from urllib3.exceptions import HTTPError
8
8
 
9
9
  from .Project import Project
@@ -34,8 +34,8 @@ class Account:
34
34
  Valid credential combinations
35
35
  -----------------------------
36
36
  username + password
37
- Classic login. If two-factor authentication (2FA) is enabled on the
38
- account, the user is prompted for the code interactively.
37
+ Classic login. Not supported for accounts with two-factor
38
+ authentication (2FA) enabled; use ``api_key`` instead.
39
39
  api_key
40
40
  API-key login. 2FA is not required.
41
41
  username + password + api_key
@@ -77,8 +77,8 @@ class Account:
77
77
  Uses the credentials set on the instance (``username``/``password``
78
78
  and/or ``api_key``). Valid combinations:
79
79
 
80
- - ``username`` + ``password``: classic login. If 2FA is enabled on
81
- the account, the user is prompted for the code interactively.
80
+ - ``username`` + ``password``: classic login. Not supported for
81
+ accounts with 2FA enabled; use ``api_key`` instead.
82
82
  - ``api_key``: API-key login. 2FA is not required.
83
83
  - ``username`` + ``password`` + ``api_key``: all values are forwarded
84
84
  to the authentication layer, which decides which credential to use.
@@ -87,6 +87,9 @@ class Account:
87
87
  ------
88
88
  qmenta.core.auth.InvalidLoginError
89
89
  When the provided credentials are invalid.
90
+ qmenta.core.auth.Needs2FAError
91
+ When the account has two-factor authentication enabled.
92
+ Generate an API key and log in with ``api_key`` instead.
90
93
  qmenta.core.platform.ConnectionError
91
94
  When the connection to the platform fails.
92
95
  qmenta.core.errors.PlatformError
@@ -99,12 +102,21 @@ class Account:
99
102
  password=self.password,
100
103
  api_key=self.api_key,
101
104
  base_url=self.baseurl,
102
- ask_for_2fa_input=True,
103
105
  )
104
106
  except InvalidLoginError as e:
105
107
  logger.error("Failed to log in: {}".format(e))
106
108
  self.auth = None
107
109
  raise
110
+ except Needs2FAError:
111
+ logger.error(
112
+ "Failed to log in: this account has two-factor "
113
+ "authentication enabled, which is not supported for "
114
+ "username/password login. Generate an API key in the "
115
+ "platform (My profile -> Credentials) and pass it as the "
116
+ "api_key argument of Account instead."
117
+ )
118
+ self.auth = None
119
+ raise
108
120
  except errors.PlatformError as e:
109
121
  logger.error("Failed to log in: {}".format(e))
110
122
  self.auth = None
@@ -1,18 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: qmenta-client
3
- Version: 3.0.0.dev1530
4
- Summary: Python client lib to interact with the QMENTA platform.
5
- Author: QMENTA
6
- Author-email: dev@qmenta.com
7
- Requires-Python: >=3.10,<4.0
8
- Classifier: Development Status :: 4 - Beta
9
- Classifier: Intended Audience :: Developers
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Requires-Dist: future (>=0.18.2,<0.19.0)
16
- Requires-Dist: pytest-cov (>=6.1.1,<7.0.0)
17
- Requires-Dist: qmenta-core (==5.0.0)
18
- Project-URL: Homepage, https://www.qmenta.com/
@@ -1,38 +0,0 @@
1
- [tool.poetry]
2
- name = "qmenta-client"
3
- version = "3.0.0.dev1530"
4
- description = "Python client lib to interact with the QMENTA platform."
5
- authors = ["QMENTA <dev@qmenta.com>"]
6
- homepage = "https://www.qmenta.com/"
7
- classifiers=[
8
- "Development Status :: 4 - Beta",
9
- "Intended Audience :: Developers",
10
- ]
11
- packages = [
12
- { include = "qmenta", from = "src" }
13
- ]
14
-
15
- [tool.poetry.dependencies]
16
- python = "^3.10"
17
- future = "^0.18.2"
18
- qmenta-core = "5.0.0"
19
- pytest-cov = "^6.1.1"
20
-
21
- [tool.poetry.group.dev.dependencies]
22
- pytest = "^7.1.2"
23
- sphinx = "^5.0"
24
- sphinx-rtd-theme = "^1.0.0"
25
- dom-toml = "^0.6.0"
26
- scriv = {version = "^0.15.2", extras = ["toml"]}
27
- coverage = "^7.2.5"
28
- flake8 = "^7.1.2"
29
- responses = "^0.25.7"
30
-
31
- [build-system]
32
- requires = ["poetry-core>=2.0.0,<3.0.0"]
33
- build-backend = "poetry.core.masonry.api"
34
-
35
- [tool.scriv]
36
- format = "md"
37
- md_header_level = "2"
38
- insert_marker = "scriv-insert-here"