brainframe-cli 0.3.2__py3-none-any.whl → 0.3.3__py3-none-any.whl

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.
@@ -1 +1 @@
1
- __version__ = "0.3.0"
1
+ __version__ = "0.3.3"
@@ -7,7 +7,6 @@ from pathlib import Path
7
7
  from tempfile import NamedTemporaryFile
8
8
  from typing import Optional
9
9
  from typing import Tuple
10
- from typing import Union
11
10
 
12
11
  import i18n
13
12
  import requests
@@ -15,9 +14,10 @@ from brainframe.cli import __version__
15
14
  from brainframe.cli import config
16
15
  from brainframe.cli import frozen_utils
17
16
  from brainframe.cli import print_utils
18
- from packaging import version
17
+ from packaging.version import Version
19
18
 
20
19
  from .utils import command
20
+ from .utils import parse_version
21
21
 
22
22
  _RELEASES_URL_PREFIX = "https://{subdomain}aotu.ai"
23
23
  _BINARY_URL = "{prefix}/releases/brainframe-cli/brainframe"
@@ -50,7 +50,7 @@ def self_update():
50
50
  )
51
51
  binary_url = _BINARY_URL.format(prefix=prefix)
52
52
 
53
- current_version = version.parse(__version__)
53
+ current_version = parse_version(__version__)
54
54
  latest_version = _latest_version(prefix, credentials)
55
55
 
56
56
  if current_version >= latest_version:
@@ -94,7 +94,7 @@ def self_update():
94
94
  def _latest_version(
95
95
  url_prefix: str,
96
96
  credentials: Optional[Tuple[str, str]],
97
- ) -> Union[version.LegacyVersion, version.Version]:
97
+ ) -> Version:
98
98
  latest_tag_url = _LATEST_TAG_URL.format(prefix=url_prefix)
99
99
  response = requests.get(latest_tag_url, auth=credentials)
100
100
 
@@ -105,7 +105,7 @@ def _latest_version(
105
105
  error_message=response.text,
106
106
  )
107
107
 
108
- return version.parse(response.text)
108
+ return parse_version(response.text)
109
109
 
110
110
 
111
111
  def _parse_args():
@@ -4,9 +4,9 @@ import i18n
4
4
  from brainframe.cli import brainframe_compose
5
5
  from brainframe.cli import config
6
6
  from brainframe.cli import print_utils
7
- from packaging import version
8
7
 
9
8
  from .utils import command
9
+ from .utils import parse_version
10
10
  from .utils import subcommand_parse_args
11
11
 
12
12
 
@@ -27,21 +27,22 @@ def update():
27
27
  install_path
28
28
  )
29
29
 
30
- existing_version = version.parse(existing_version_str)
31
- requested_version = version.parse(requested_version_str)
32
-
33
- force_downgrade = False
34
- if args.noninteractive:
35
- # Use the --force flag to decide if downgrades are allowed
36
- force_downgrade = args.force
37
- else:
38
- # Ask the user if downgrades should be allowed
39
- if existing_version >= requested_version:
40
- force_downgrade = print_utils.ask_yes_no(
41
- "update.ask-force-downgrade"
42
- )
43
-
44
- if not force_downgrade:
30
+ existing_version = parse_version(existing_version_str)
31
+ requested_version = parse_version(requested_version_str)
32
+
33
+ force = args.force
34
+ if (
35
+ not force
36
+ and not args.noninteractive
37
+ and existing_version > requested_version
38
+ ):
39
+ force = print_utils.ask_yes_no(
40
+ "update.ask-force-downgrade",
41
+ existing_version=existing_version_str,
42
+ requested_version=requested_version_str,
43
+ )
44
+
45
+ if not force:
45
46
  # Fail if the requested version is not an upgrade
46
47
  if existing_version == requested_version:
47
48
  print_utils.fail_translate(
@@ -105,6 +106,7 @@ def _parse_args():
105
106
  )
106
107
 
107
108
  parser.add_argument(
109
+ "-f",
108
110
  "--force",
109
111
  action="store_true",
110
112
  help=i18n.t("update.force-help"),
@@ -6,6 +6,7 @@ from typing import Callable
6
6
 
7
7
  from brainframe.cli import os_utils
8
8
  from brainframe.cli import print_utils
9
+ from packaging import version
9
10
 
10
11
  by_name = {}
11
12
  """A dict that maps command names to their corresponding function"""
@@ -42,3 +43,14 @@ def requires_root(function: Callable) -> Callable:
42
43
  return function(*args, **kwargs)
43
44
 
44
45
  return wrapper
46
+
47
+
48
+ def parse_version(version_str: str) -> version.Version:
49
+ """Parses a version string, exiting with a readable error if it is
50
+ malformed."""
51
+ try:
52
+ return version.Version(version_str.strip())
53
+ except version.InvalidVersion:
54
+ print_utils.fail_translate(
55
+ "general.invalid-version", version=version_str.strip()
56
+ )
brainframe/cli/config.py CHANGED
@@ -1,5 +1,4 @@
1
1
  import os
2
- from distutils.util import strtobool
3
2
  from pathlib import Path
4
3
  from typing import Callable
5
4
  from typing import Dict
@@ -92,4 +91,9 @@ def _bool_converter(value: Union[str, bool]) -> bool:
92
91
  if isinstance(value, bool):
93
92
  return value
94
93
 
95
- return bool(strtobool(value))
94
+ normalized = value.lower()
95
+ if normalized in ("y", "yes", "t", "true", "on", "1"):
96
+ return True
97
+ if normalized in ("n", "no", "f", "false", "off", "0"):
98
+ return False
99
+ raise ValueError("invalid truth value {!r}".format(value))
@@ -34,3 +34,4 @@ en:
34
34
  missing-defaults-file: "This distribution is missing a defaults file. Please
35
35
  re-install the latest version of the BrainFrame CLI and try again."
36
36
  interrupted: "The operation was interrupted"
37
+ invalid-version: "\"%{version}\" is not a valid version number."
@@ -13,11 +13,6 @@ en:
13
13
  complete: "BrainFrame has been updated!"
14
14
  upgrade-version: "BrainFrame:%{existing_version} detected under your installation
15
15
  location, we will replace it with BrainFrame:%{requested_version}"
16
- version-failing: "You have BrainFrame:%{existing_version} installed already.
17
- The latest available version is BrainFrame:%{upgrade_version}. We don't
18
- recommend downgrading BrainFrame for data integrity reasons. This request
19
- will be ignored. You can force a downgrade by also supplying the --downgrade
20
- flag."
21
16
  version-already-installed: "BrainFrame:%{existing_version} is already
22
17
  installed. This request will be ignored. You can force this release to be
23
18
  re-downloaded using the --force flag."
@@ -26,6 +21,6 @@ en:
26
21
  don't recommend downgrading BrainFrame for data integrity reasons. This
27
22
  request will be ignored. You can force a downgrade using the --force flag."
28
23
  ask-force-downgrade: "BrainFrame:%{requested_version} does not appear to
29
- be a newer version then the current version, BrainFrame:%{existing_version}.
24
+ be a newer version than the current version, BrainFrame:%{existing_version}.
30
25
  Downgrading BrainFrame is not officially supported and may lead to data loss.
31
26
  Are you sure you want to continue?"
@@ -1,22 +1,27 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: brainframe-cli
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Makes installing and managing a BrainFrame server easy
5
5
  Home-page: https://github.com/aotuai/brainframe_cli
6
6
  License: BSD-3-Clause
7
7
  Author: Aotu.ai
8
8
  Author-email: info@aotu.ai
9
- Requires-Python: >=3.10,<4.0
9
+ Requires-Python: >=3.6.9,<3.13
10
10
  Classifier: License :: OSI Approved :: BSD License
11
11
  Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.7
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
12
15
  Classifier: Programming Language :: Python :: 3.10
13
16
  Classifier: Programming Language :: Python :: 3.11
14
17
  Classifier: Programming Language :: Python :: 3.12
15
18
  Requires-Dist: distro (>=1.5,<2.0)
16
19
  Requires-Dist: docker (>4.3.1,<7.0.0)
17
- Requires-Dist: packaging (>=20.4,<21.0)
20
+ Requires-Dist: docker-compose (>=1.29.2,<2.0.0) ; python_version < "3.10"
21
+ Requires-Dist: packaging (>=20.4)
18
22
  Requires-Dist: python-i18n (>=0.3,<0.4)
19
- Requires-Dist: pyyaml (>=6.0)
23
+ Requires-Dist: pyyaml (>=3.10,<6) ; python_version < "3.10"
24
+ Requires-Dist: pyyaml (>=6.0) ; python_version >= "3.10"
20
25
  Requires-Dist: requests (>=2.24.0,<3.0.0)
21
26
  Requires-Dist: websocket-client (>=0.32.0,<1.0)
22
27
  Project-URL: Repository, https://github.com/aotuai/brainframe_cli
@@ -65,6 +70,18 @@ using the ``compose`` command, which can be run from any directory.
65
70
 
66
71
  brainframe compose up -d
67
72
 
73
+ The following will show logs,
74
+
75
+ .. code-block::
76
+
77
+ brainframe compose logs -f core journal
78
+
79
+ How to integrate the following to cleanup logs,
80
+
81
+ .. code-block::
82
+
83
+ sudo truncate -s 0 $(docker inspect --format='{{.LogPath}}' brainframe-core-1 brainframe-journal-1)
84
+
68
85
  For more information, take a look at the `Getting Started guide`_.
69
86
 
70
87
  .. _`Getting Started guide`: https://aotu.ai/docs/getting_started/
@@ -87,35 +104,53 @@ your code to fit our guidelines:
87
104
  poetry run isort .
88
105
  poetry run black .
89
106
 
90
- Build & install local build for test:
107
+ Build one PyPI wheel for Python 3.6–3.12. The wheel records different
108
+ dependencies for older and newer Python versions:
91
109
 
92
110
  .. code-block:: bash
93
111
 
94
- python3 deployment/build.py --version 3.8
95
- python3 deployment/build.py --version 3.10 3.12
96
- pip install dist/brainframe_cli-0.3.0-py3-none-any.whl
112
+ deployment/ide_cli build wheel-env
113
+ deployment/ide_cli build wheel
114
+
115
+ To validate the wheel and intended destination without uploading, run
116
+ ``deployment/ide_cli push wheel --dry-run``. After configuring a TestPyPI token
117
+ with ``TWINE_USERNAME`` and ``TWINE_PASSWORD`` or ``~/.pypirc``, run
118
+ ``deployment/ide_cli push wheel``. Add ``--pypi`` to publish to production PyPI.
97
119
 
98
- The above build.py will copy pyproject.toml & poetry.lock in deployment folder
99
- to the project root, and automatically run poetry build. Similar to below,
120
+ Build the PyInstaller standalone Linux executable separately:
100
121
 
101
122
  .. code-block:: bash
102
123
 
103
- poetry build
104
- pip install dist/brainframe_cli-0.3.0-py3-none-any.whl
124
+ deployment/ide_cli build pyinstaller-binary-env
125
+ deployment/ide_cli build pyinstaller-binary
105
126
 
106
- The wheel build & test commands have been integrated in deployment/do script,
107
- which support build & test on Ubuntu 18.04/20.04/22.04/24.04
127
+ This creates ``dist/brainframe``. To publish it to the dev releases bucket,
128
+ run ``deployment/ide_cli push pyinstaller-to-aws`` with an AWS profile and
129
+ region. Add ``--prod`` for the production releases bucket.
130
+
131
+ Debian packages use ``build deb-env`` and ``build deb``. That build path is
132
+ currently not release-ready.
133
+
134
+ To remove generated wheels, the standalone executable, Debian packages, and
135
+ Debian staging files before a fresh build:
108
136
 
109
137
  .. code-block:: bash
110
138
 
111
- deployment/do
139
+ deployment/ide_cli clean
112
140
 
113
- Pyinstaller build:
141
+ ``clean`` restores ``brainframe/cli/defaults.yaml`` if it still matches the
142
+ system-package copy left by a Debian build. It stops if that file has other
143
+ edits. Docker images remain cached; pass ``--no-cache`` to a ``*-env`` build when
144
+ testing the image build from scratch.
114
145
 
115
- The result will be in the dist/ directory
146
+ The wheel build uses one Python 3.12 Docker image and writes one wheel to
147
+ ``dist/``. Install it for local testing with:
116
148
 
117
149
  .. code-block:: bash
118
150
 
119
- pyinstaller package/main.spec
151
+ pip install dist/brainframe_cli-0.3.3-py3-none-any.whl
152
+
153
+ Once the Docker environments exist, rerun ``build wheel`` or
154
+ ``build pyinstaller-binary`` without rebuilding them.
120
155
 
121
156
 
@@ -1,4 +1,4 @@
1
- brainframe/cli/__init__.py,sha256=VrXpHDu3erkzwl_WXrqINBm9xWkcyUy53IQOj042dOs,22
1
+ brainframe/cli/__init__.py,sha256=8KcCYTXH99C2-gCLuPILJvtT9YftRWJsartIx6TQ2ZY,22
2
2
  brainframe/cli/brainframe_compose.py,sha256=VUFkd9dSD5HiwVej4p-wFvdyKfaPklCcWEAKz7JKWw4,5998
3
3
  brainframe/cli/brainframe_shell.py,sha256=6-R3TtIGJGyZipdxV414f3_BKKXrQiTfY6dabncDtoc,788
4
4
  brainframe/cli/commands/__init__.py,sha256=eQA24GuE8YSm6RJL86Kv1vVMtjfG565xVqhfheGtRAM,257
@@ -6,12 +6,12 @@ brainframe/cli/commands/backup.py,sha256=HFAs42dO4kjxQey09AOOGEEcPiVinTv9NArkP05
6
6
  brainframe/cli/commands/compose.py,sha256=Io73Ao-sddbbUhf89JZoxMptjH2Dcmx6FJVsBgxqEfI,311
7
7
  brainframe/cli/commands/info.py,sha256=WXMfLoeyYCosl9__T1Tpsh5EN3CadxQpTCYAXYCMdUE,1230
8
8
  brainframe/cli/commands/install.py,sha256=93mQ7_3ufvC_9bpJaaJ9Onm-4wY6OvkoKtHHr84AWiE,5785
9
- brainframe/cli/commands/self_update.py,sha256=tPV5hNDkUDF83KGjD85WCtb_pzA4526mAQvhCMBwYQs,3648
9
+ brainframe/cli/commands/self_update.py,sha256=ShnceP4wZuGKaKIyHjxtafnljpv_ERjU-QchVzZHPIg,3626
10
10
  brainframe/cli/commands/shell.py,sha256=cWIx8qcwHrjKMU-vSOrLuY5YNyJVedv6V-fF9cb5Y04,422
11
11
  brainframe/cli/commands/uninstall.py,sha256=yS6THcnALobh8pDmB4E8vlZIrnLNL5Ee0tORUi9p4qo,2203
12
- brainframe/cli/commands/update.py,sha256=Sxpq8a_1EF8WGqLpLbt9XBuNuvHc-uRnZSrubSec4Rw,3300
13
- brainframe/cli/commands/utils.py,sha256=DmplbA6tXwdYQ6kAEvPgvuhPlQ3ycscYJNIFYaDPH9o,1082
14
- brainframe/cli/config.py,sha256=aS8kV-RtYTUSiHRjzZYqJ0Jk46cj__1ETLOj_AjRSk0,2699
12
+ brainframe/cli/commands/update.py,sha256=uIyaq2HWtHkf4DhDYIkNgLBFjNvNiepAWe06jw3HZdM,3257
13
+ brainframe/cli/commands/utils.py,sha256=LLPYUpWQ_F6BBeQZJaBN_dAOTE07pZrew8BGA-ScVaA,1468
14
+ brainframe/cli/config.py,sha256=Ezd_8HyCqDAr7QgA7CPic2OszUI-KKjuQzLVy6RhjY4,2882
15
15
  brainframe/cli/defaults.yaml,sha256=mcg0pt52Xy7UWc-etFsbVqYn6sZ2EtJbwS4W-m2cYPA,142
16
16
  brainframe/cli/dependencies.py,sha256=UyrOxkOvka7qy5xjPHIuYmNqTjrJDVNmnuUow_6IVA4,2435
17
17
  brainframe/cli/frozen_utils.py,sha256=rPW37TdO7n4aitHtD0w2aq3IbyntJVcnT9096NgvIXc,1377
@@ -19,16 +19,15 @@ brainframe/cli/main.py,sha256=NhYU3Gwvr-a7lCr__wA0LBGT0RSUKdmFm2ASZbjEVUA,1862
19
19
  brainframe/cli/os_utils.py,sha256=wxLk27Uj-FJkBzcJT4T6boEFDW8QBlRGU1Nt5ZGaEWA,5569
20
20
  brainframe/cli/print_utils.py,sha256=liIvGsyWRFbPkLUeAjcbUhWB4vRkDn9TyxKUnmzAmf0,3472
21
21
  brainframe/cli/translations/backup.en.yml,sha256=91dOE4JH_TPdKp8vRAJ3grnBVB5_jHjZsm8nF_bdOAI,1163
22
- brainframe/cli/translations/general.en.yml,sha256=Da321e7E0t0BcCieM8iExffBV1EeUgVgPTZeisUIUTc,2015
22
+ brainframe/cli/translations/general.en.yml,sha256=-yA7-AoCwg8ArLMTYN21UpxHhQGXSIoFm5uMtw8ki-M,2082
23
23
  brainframe/cli/translations/info.en.yml,sha256=6dj1hstvTQ5F9UYjcK8PQaCz2zuFdtgGkAd4OAoS-BU,262
24
24
  brainframe/cli/translations/install.en.yml,sha256=qmeVCTm-iR3bf4HNql3ieUT6TFxXTgHMHEyK2c6cwHE,3909
25
25
  brainframe/cli/translations/portal.en.yml,sha256=TAPrYBb3vF6BSwKclMtRjSs3zTJt9lNAJ5k5gVpUw_U,1406
26
26
  brainframe/cli/translations/self-update.en.yml,sha256=5_p5uEuTpSMi6FJBTTxrKhn9E38PLqWrW0nk4nNAyfE,732
27
27
  brainframe/cli/translations/shell.en.yml,sha256=93gpkVProI4zyfXgf5HI5DctyOM58T3wQXBwLKJVpsU,396
28
28
  brainframe/cli/translations/uninstall.en.yml,sha256=z6ZSQljS2P9AEPnfk9vbs6uLBoVQJXHLH_-z4P3-seU,1149
29
- brainframe/cli/translations/update.en.yml,sha256=o9mjpipmKYcUzrP_36PBmrOI-sgA55t31gCV-neYdwI,1913
30
- brainframe_cli-0.3.2.dist-info/COPYING,sha256=gUdx8BDkY31TjlE3BXyajv8oSs-1hxBD4NUn-hUZi6w,1502
31
- brainframe_cli-0.3.2.dist-info/METADATA,sha256=9WC8FqUCjCFulvTnZCC_BmYt8WQzp-gx7CNMLGv2AVs,3168
32
- brainframe_cli-0.3.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
33
- brainframe_cli-0.3.2.dist-info/entry_points.txt,sha256=Tah5GI0gjeVzUGLJSPd5eIYQHb80Z2f7qEPtDQa1FPE,55
34
- brainframe_cli-0.3.2.dist-info/RECORD,,
29
+ brainframe/cli/translations/update.en.yml,sha256=qWQxXjGXcLxAsZMrPHkkDQzYvluleMsR5oVq-3RShyY,1596
30
+ brainframe_cli-0.3.3.dist-info/METADATA,sha256=oq6nOLC0ZmJkeYonIbEtISKk9fuOozWDoAy5RTq_7RM,4753
31
+ brainframe_cli-0.3.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
+ brainframe_cli-0.3.3.dist-info/entry_points.txt,sha256=Tah5GI0gjeVzUGLJSPd5eIYQHb80Z2f7qEPtDQa1FPE,55
33
+ brainframe_cli-0.3.3.dist-info/RECORD,,
@@ -1,26 +0,0 @@
1
- Copyright (C) 2020, Dilili Labs INC, all rights reserved.
2
-
3
- Redistribution and use in source and binary forms, with or without
4
- modification, are permitted provided that the following conditions are met:
5
-
6
- 1. Redistributions of source code must retain the above copyright notice, this
7
- list of conditions and the following disclaimer.
8
-
9
- 2. Redistributions in binary form must reproduce the above copyright notice,
10
- this list of conditions and the following disclaimer in the documentation
11
- and/or other materials provided with the distribution.
12
-
13
- 3. Neither the name of the copyright holder nor the names of its contributors
14
- may be used to endorse or promote products derived from this software without
15
- specific prior written permission.
16
-
17
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.