diracx-testing 0.0.1a20__py3-none-any.whl → 0.0.1a22__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.
@@ -6,10 +6,14 @@ import asyncio
6
6
  import contextlib
7
7
  import os
8
8
  import re
9
+ import ssl
9
10
  import subprocess
11
+ import tomllib
12
+ from collections import defaultdict
10
13
  from datetime import datetime, timedelta, timezone
11
14
  from functools import partial
12
15
  from html.parser import HTMLParser
16
+ from importlib.metadata import PackageNotFoundError, distribution, entry_points
13
17
  from pathlib import Path
14
18
  from typing import TYPE_CHECKING
15
19
  from urllib.parse import parse_qs, urljoin, urlparse
@@ -20,7 +24,7 @@ import requests
20
24
 
21
25
  if TYPE_CHECKING:
22
26
  from diracx.core.settings import DevelopmentSettings
23
- from diracx.routers.job_manager.sandboxes import SandboxStoreSettings
27
+ from diracx.routers.jobs.sandboxes import SandboxStoreSettings
24
28
  from diracx.routers.utils.users import AuthorizedUserInfo, AuthSettings
25
29
 
26
30
 
@@ -123,7 +127,7 @@ def aio_moto(worker_id):
123
127
 
124
128
  @pytest.fixture(scope="session")
125
129
  def test_sandbox_settings(aio_moto) -> SandboxStoreSettings:
126
- from diracx.routers.job_manager.sandboxes import SandboxStoreSettings
130
+ from diracx.routers.jobs.sandboxes import SandboxStoreSettings
127
131
 
128
132
  yield SandboxStoreSettings(
129
133
  bucket_name="sandboxes",
@@ -456,6 +460,50 @@ def with_config_repo(tmp_path_factory):
456
460
  }
457
461
  },
458
462
  "Operations": {"Defaults": {}},
463
+ "Systems": {
464
+ "WorkloadManagement": {
465
+ "Production": {
466
+ "Databases": {
467
+ "JobDB": {
468
+ "DBName": "xyz",
469
+ "Host": "xyz",
470
+ "Port": 9999,
471
+ "MaxRescheduling": 3,
472
+ },
473
+ "JobLoggingDB": {
474
+ "DBName": "xyz",
475
+ "Host": "xyz",
476
+ "Port": 9999,
477
+ },
478
+ "PilotAgentsDB": {
479
+ "DBName": "xyz",
480
+ "Host": "xyz",
481
+ "Port": 9999,
482
+ },
483
+ "SandboxMetadataDB": {
484
+ "DBName": "xyz",
485
+ "Host": "xyz",
486
+ "Port": 9999,
487
+ },
488
+ "TaskQueueDB": {
489
+ "DBName": "xyz",
490
+ "Host": "xyz",
491
+ "Port": 9999,
492
+ },
493
+ "ElasticJobParametersDB": {
494
+ "DBName": "xyz",
495
+ "Host": "xyz",
496
+ "Port": 9999,
497
+ },
498
+ "VirtualMachineDB": {
499
+ "DBName": "xyz",
500
+ "Host": "xyz",
501
+ "Port": 9999,
502
+ },
503
+ },
504
+ },
505
+ },
506
+ },
459
507
  }
460
508
  )
461
509
  cs_file.write_text(example_cs.model_dump_json())
@@ -516,7 +564,11 @@ def cli_env(monkeypatch, tmp_path, demo_urls, demo_dir):
516
564
  raise RuntimeError(f"Could not find {ca_path}, is the demo running?")
517
565
 
518
566
  # Ensure the demo is working
519
- r = httpx.get(f"{diracx_url}/api/openapi.json", verify=ca_path)
567
+
568
+ r = httpx.get(
569
+ f"{diracx_url}/api/openapi.json",
570
+ verify=ssl.create_default_context(cafile=ca_path),
571
+ )
520
572
  r.raise_for_status()
521
573
  assert r.json()["info"]["title"] == "Dirac"
522
574
 
@@ -637,3 +689,63 @@ def do_device_flow_with_dex(url: str, ca_path: str) -> None:
637
689
 
638
690
  # This should have redirected to the DiracX page that shows the login is complete
639
691
  assert "Please close the window" in r.text
692
+
693
+
694
+ def get_installed_entry_points():
695
+ """Retrieve the installed entry points from the environment."""
696
+ entry_pts = entry_points()
697
+ diracx_eps = defaultdict(dict)
698
+ for group in entry_pts.groups:
699
+ if "diracx" in group:
700
+ for ep in entry_pts.select(group=group):
701
+ diracx_eps[group][ep.name] = ep.value
702
+ return dict(diracx_eps)
703
+
704
+
705
+ def get_entry_points_from_toml(toml_file):
706
+ """Parse entry points from pyproject.toml."""
707
+ with open(toml_file, "rb") as f:
708
+ pyproject = tomllib.load(f)
709
+ package_name = pyproject["project"]["name"]
710
+ return package_name, pyproject.get("project", {}).get("entry-points", {})
711
+
712
+
713
+ def get_current_entry_points(repo_base) -> bool:
714
+ """Create current entry points dict for comparison."""
715
+ current_eps = {}
716
+ for toml_file in repo_base.glob("diracx-*/pyproject.toml"):
717
+ package_name, entry_pts = get_entry_points_from_toml(f"{toml_file}")
718
+ # Ignore packages that are not installed
719
+ try:
720
+ distribution(package_name)
721
+ except PackageNotFoundError:
722
+ continue
723
+ # Merge the entry points
724
+ for key, value in entry_pts.items():
725
+ current_eps[key] = current_eps.get(key, {}) | value
726
+ return current_eps
727
+
728
+
729
+ @pytest.fixture(scope="session", autouse=True)
730
+ def verify_entry_points(request, pytestconfig):
731
+ try:
732
+ ini_toml_name = tomllib.loads(pytestconfig.inipath.read_text())["project"][
733
+ "name"
734
+ ]
735
+ except tomllib.TOMLDecodeError:
736
+ return
737
+ if ini_toml_name == "diracx":
738
+ repo_base = pytestconfig.inipath.parent
739
+ elif ini_toml_name.startswith("diracx-"):
740
+ repo_base = pytestconfig.inipath.parent.parent
741
+ else:
742
+ return
743
+
744
+ installed_eps = get_installed_entry_points()
745
+ current_eps = get_current_entry_points(repo_base)
746
+
747
+ if installed_eps != current_eps:
748
+ pytest.fail(
749
+ "Project and installed entry-points are not consistent. "
750
+ "You should run `pip install -r requirements-dev.txt`",
751
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diracx-testing
3
- Version: 0.0.1a20
3
+ Version: 0.0.1a22
4
4
  Summary: TODO
5
5
  License: GPL-3.0-only
6
6
  Classifier: Intended Audience :: Science/Research
@@ -1,9 +1,9 @@
1
- diracx/testing/__init__.py,sha256=vuPYuD45HWaIJKJ2mp8GCHWMy7JH7q4YsEmJF_2BEgQ,21658
1
+ diracx/testing/__init__.py,sha256=T1gt7D7PjgbzyxIYN5gXMKbxGnHhE5qm0ORvJ6sspCs,25717
2
2
  diracx/testing/dummy_osdb.py,sha256=bNk3LF8KgMuQx3RVFNYuw4hMmpG2A80sZ58rEZqHo7M,907
3
3
  diracx/testing/mock_osdb.py,sha256=1TFb3b0xDb2vIy4Q4V23VtrsWoT3RE5kOZmOs8n541g,5862
4
4
  diracx/testing/osdb.py,sha256=m6mUBLnGOoQLTCIBie9P2GhmLMybrgzIrlIYfhF1_Ss,3230
5
5
  diracx/testing/routers.py,sha256=UW-TnikMQgcNxF5sUZD5DWoucGiCpP6s8mYmuahDiSc,979
6
- diracx_testing-0.0.1a20.dist-info/METADATA,sha256=GMrpB-ANxo89dX7e3Bpmn5jLHYHh3nXRm71rWBRoFIg,613
7
- diracx_testing-0.0.1a20.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
8
- diracx_testing-0.0.1a20.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
9
- diracx_testing-0.0.1a20.dist-info/RECORD,,
6
+ diracx_testing-0.0.1a22.dist-info/METADATA,sha256=v0Iwfl9bbkfwoonPQNsMIJhkn1Y-bHbt-DIlI1lo6b0,613
7
+ diracx_testing-0.0.1a22.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
8
+ diracx_testing-0.0.1a22.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
9
+ diracx_testing-0.0.1a22.dist-info/RECORD,,