diracx-cli 0.0.1a43__py3-none-any.whl → 0.0.1a45__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.
diracx/cli/auth.py CHANGED
@@ -124,7 +124,9 @@ async def logout():
124
124
 
125
125
  # Revoke refresh token
126
126
  try:
127
- await api.auth.revoke_refresh_token(credentials.refresh_token)
127
+ await api.auth.revoke_refresh_token_by_refresh_token(
128
+ client_id=api.client_id, refresh_token=credentials.refresh_token
129
+ )
128
130
  except Exception as e:
129
131
  print(f"Error revoking the refresh token {e!r}")
130
132
  pass
@@ -132,6 +134,9 @@ async def logout():
132
134
  # Remove credentials
133
135
  credentials_path.unlink(missing_ok=True)
134
136
  print(f"Removed credentials from {credentials_path}")
137
+ else:
138
+ print("You are not connected to DiracX, or your credentials are missing.")
139
+ return
135
140
  print("\nLogout successful!")
136
141
 
137
142
 
@@ -24,14 +24,27 @@ from ..utils import AsyncTyper
24
24
  app = AsyncTyper()
25
25
 
26
26
 
27
+ def get_repo_path(config_repo_str: str) -> Path:
28
+ config_repo = TypeAdapter(ConfigSourceUrl).validate_python(config_repo_str)
29
+ if config_repo.scheme != "git+file" or config_repo.path is None:
30
+ raise NotImplementedError("Only git+file:// URLs are supported")
31
+
32
+ repo_path = Path(config_repo.path)
33
+
34
+ return repo_path
35
+
36
+
37
+ def get_config_from_repo_path(repo_path: Path) -> Config:
38
+ return ConfigSource.create_from_url(backend_url=repo_path).read_config()
39
+
40
+
27
41
  @app.command()
28
42
  def generate_cs(config_repo: str):
29
43
  """Generate a minimal DiracX configuration repository."""
30
44
  # TODO: The use of TypeAdapter should be moved in to typer itself
31
- config_repo = TypeAdapter(ConfigSourceUrl).validate_python(config_repo)
32
- if config_repo.scheme != "git+file" or config_repo.path is None:
33
- raise NotImplementedError("Only git+file:// URLs are supported")
34
- repo_path = Path(config_repo.path)
45
+
46
+ repo_path = get_repo_path(config_repo)
47
+
35
48
  if repo_path.exists() and list(repo_path.iterdir()):
36
49
  typer.echo(f"ERROR: Directory {repo_path} already exists", err=True)
37
50
  raise typer.Exit(1)
@@ -60,10 +73,8 @@ def add_vo(
60
73
  ):
61
74
  """Add a registry entry (vo) to an existing configuration repository."""
62
75
  # TODO: The use of TypeAdapter should be moved in to typer itself
63
- config_repo = TypeAdapter(ConfigSourceUrl).validate_python(config_repo)
64
- if config_repo.scheme != "git+file" or config_repo.path is None:
65
- raise NotImplementedError("Only git+file:// URLs are supported")
66
- repo_path = Path(config_repo.path)
76
+ repo_path = get_repo_path(config_repo)
77
+ config = get_config_from_repo_path(repo_path)
67
78
 
68
79
  # A VO should at least contain a default group
69
80
  new_registry = RegistryConfig(
@@ -77,8 +88,6 @@ def add_vo(
77
88
  },
78
89
  )
79
90
 
80
- config = ConfigSource.create_from_url(backend_url=repo_path).read_config()
81
-
82
91
  if vo in config.Registry:
83
92
  typer.echo(f"ERROR: VO {vo} already exists", err=True)
84
93
  raise typer.Exit(1)
@@ -103,15 +112,11 @@ def add_group(
103
112
  ):
104
113
  """Add a group to an existing vo in the configuration repository."""
105
114
  # TODO: The use of TypeAdapter should be moved in to typer itself
106
- config_repo = TypeAdapter(ConfigSourceUrl).validate_python(config_repo)
107
- if config_repo.scheme != "git+file" or config_repo.path is None:
108
- raise NotImplementedError("Only git+file:// URLs are supported")
109
- repo_path = Path(config_repo.path)
115
+ repo_path = get_repo_path(config_repo)
116
+ config = get_config_from_repo_path(repo_path)
110
117
 
111
118
  new_group = GroupConfig(Properties=set(properties), Quota=None, Users=set())
112
119
 
113
- config = ConfigSource.create_from_url(backend_url=repo_path).read_config()
114
-
115
120
  if vo not in config.Registry:
116
121
  typer.echo(f"ERROR: Virtual Organization {vo} does not exist", err=True)
117
122
  raise typer.Exit(1)
@@ -139,16 +144,11 @@ def add_user(
139
144
  ):
140
145
  """Add a user to an existing vo and group."""
141
146
  # TODO: The use of TypeAdapter should be moved in to typer itself
142
- config_repo = TypeAdapter(ConfigSourceUrl).validate_python(config_repo)
143
- if config_repo.scheme != "git+file" or config_repo.path is None:
144
- raise NotImplementedError("Only git+file:// URLs are supported")
145
-
146
- repo_path = Path(config_repo.path)
147
+ repo_path = get_repo_path(config_repo)
148
+ config = get_config_from_repo_path(repo_path)
147
149
 
148
150
  new_user = UserConfig(PreferedUsername=preferred_username)
149
151
 
150
- config = ConfigSource.create_from_url(backend_url=repo_path).read_config()
151
-
152
152
  if vo not in config.Registry:
153
153
  typer.echo(f"ERROR: Virtual Organization {vo} does not exist", err=True)
154
154
  raise typer.Exit(1)
@@ -96,7 +96,7 @@ def _apply_fixes(raw):
96
96
  raw["DIRAC"].pop("Framework", None)
97
97
  raw["DIRAC"].pop("Security", None)
98
98
 
99
- # This is VOMS specific and no longer reqired
99
+ # This is VOMS specific and no longer required
100
100
  raw["DIRAC"].pop("ConnConf", None)
101
101
 
102
102
  # Setups are no longer supported
diracx/cli/utils.py CHANGED
@@ -7,6 +7,7 @@ from functools import wraps
7
7
 
8
8
  import typer
9
9
  from azure.core.exceptions import ClientAuthenticationError
10
+ from httpx import ConnectError
10
11
  from rich import print
11
12
 
12
13
 
@@ -22,6 +23,10 @@ class AsyncTyper(typer.Typer):
22
23
  ":x: [bold red]You are not authenticated. Log in with:[/bold red] "
23
24
  "[bold] dirac login [OPTIONS] [VO] [/bold]"
24
25
  )
26
+ except ConnectError:
27
+ print(
28
+ ":x: [bold red]Please configure a valid DiracX server.[/bold red]"
29
+ )
25
30
 
26
31
  self.command(*args, **kwargs)(sync_func)
27
32
  return async_func
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diracx-cli
3
- Version: 0.0.1a43
3
+ Version: 0.0.1a45
4
4
  Summary: TODO
5
5
  License: GPL-3.0-only
6
6
  Classifier: Intended Audience :: Science/Research
@@ -9,17 +9,16 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Topic :: Scientific/Engineering
10
10
  Classifier: Topic :: System :: Distributed Computing
11
11
  Requires-Python: >=3.11
12
- Description-Content-Type: text/markdown
13
12
  Requires-Dist: diraccfg
14
13
  Requires-Dist: diracx-api
15
14
  Requires-Dist: diracx-client
16
15
  Requires-Dist: diracx-core
17
16
  Requires-Dist: gitpython
18
17
  Requires-Dist: pydantic>=2.10
18
+ Requires-Dist: pyyaml
19
19
  Requires-Dist: rich
20
20
  Requires-Dist: typer>=0.12.4
21
- Requires-Dist: pyyaml
22
21
  Provides-Extra: testing
23
- Requires-Dist: diracx-testing; extra == "testing"
22
+ Requires-Dist: diracx-testing; extra == 'testing'
24
23
  Provides-Extra: types
25
- Requires-Dist: types-PyYAML; extra == "types"
24
+ Requires-Dist: types-pyyaml; extra == 'types'
@@ -0,0 +1,14 @@
1
+ diracx/cli/__init__.py,sha256=HB9Umd1DXskg8lrRY0ZnSaOBVYPD5Pl4PYRWts-ZR0E,808
2
+ diracx/cli/__main__.py,sha256=yGjYWjRcrrp5mJ0xD0v3rc7VIA9bzDib5D7LPAdH4OI,92
3
+ diracx/cli/auth.py,sha256=UZ_vhDv2K9qMH_pSFn-6hA6hL7QmBY1a_DzvLoTp-EQ,5003
4
+ diracx/cli/config.py,sha256=LDoFT4x0VF0QAU2_y-fkZWQwD7yMYmyiM7VJFLK79GQ,863
5
+ diracx/cli/jobs.py,sha256=ev3Zm6WH9g5MVT5EXbfSwHamiQUcatT4bYUrxx4c8BE,4729
6
+ diracx/cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ diracx/cli/utils.py,sha256=--kP1lOO4yky81nxmej8IQz1v6njxn_WYol5O9LcJ04,1063
8
+ diracx/cli/internal/__init__.py,sha256=KZrzVcKu3YhNev2XF2KA2nttAa9ONU3CVUgatVMonJ4,143
9
+ diracx/cli/internal/config.py,sha256=T5bf9brG1oCQkQ6D7Em4z7Fk--2Q-nPtUbe2jv-syUU,6079
10
+ diracx/cli/internal/legacy.py,sha256=zfdqO-ydFSkio2CTIcHXlObAwhBq25WNZgdChkdZ1LE,13548
11
+ diracx_cli-0.0.1a45.dist-info/METADATA,sha256=EWz-8JC4mvAfdgsyYZ7d3939eQ0jRi87TTrz6n5CP_A,763
12
+ diracx_cli-0.0.1a45.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ diracx_cli-0.0.1a45.dist-info/entry_points.txt,sha256=b1909GHVOkFUiHVglNlpwia4Ug-7Ncrg-8D5xtYVAlw,169
14
+ diracx_cli-0.0.1a45.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
-
@@ -1,15 +0,0 @@
1
- diracx/cli/__init__.py,sha256=HB9Umd1DXskg8lrRY0ZnSaOBVYPD5Pl4PYRWts-ZR0E,808
2
- diracx/cli/__main__.py,sha256=yGjYWjRcrrp5mJ0xD0v3rc7VIA9bzDib5D7LPAdH4OI,92
3
- diracx/cli/auth.py,sha256=FXpZQATi0P_xZCLCqQJ_h-hszqShd-4SD1zQ03-PXPU,4789
4
- diracx/cli/config.py,sha256=LDoFT4x0VF0QAU2_y-fkZWQwD7yMYmyiM7VJFLK79GQ,863
5
- diracx/cli/jobs.py,sha256=ev3Zm6WH9g5MVT5EXbfSwHamiQUcatT4bYUrxx4c8BE,4729
6
- diracx/cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- diracx/cli/utils.py,sha256=NwhMMHwveKOdW2aoSqpnLnfOKhPnjmPPLpX69naPAzc,855
8
- diracx/cli/internal/__init__.py,sha256=KZrzVcKu3YhNev2XF2KA2nttAa9ONU3CVUgatVMonJ4,143
9
- diracx/cli/internal/config.py,sha256=xPT7lnJ3QPqJgaNJuMoUpV6CIIxZY_d7HKFb4uINb_8,6552
10
- diracx/cli/internal/legacy.py,sha256=Wzfdgjbt9xxUK6MkCrEGNXdMOJzkvUGJh2MnD2j_2QE,13547
11
- diracx_cli-0.0.1a43.dist-info/METADATA,sha256=VaeBqDoMIktkW2WcbVTNRKjYL7D05UbKoMQpiArqYts,803
12
- diracx_cli-0.0.1a43.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
13
- diracx_cli-0.0.1a43.dist-info/entry_points.txt,sha256=b1909GHVOkFUiHVglNlpwia4Ug-7Ncrg-8D5xtYVAlw,169
14
- diracx_cli-0.0.1a43.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
15
- diracx_cli-0.0.1a43.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- diracx