coiled 1.121.1.dev19__py3-none-any.whl → 1.121.1.dev20__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.

Potentially problematic release.


This version of coiled might be problematic. Click here for more details.

coiled/software_utils.py CHANGED
@@ -595,6 +595,126 @@ def get_mamba_auth(netloc: str) -> tuple[str, str] | None:
595
595
  return get_mamba_auth_dict().get(netloc, None)
596
596
 
597
597
 
598
+ def _parse_rattler_auth_data(auth_data: dict) -> tuple[str, str] | None:
599
+ """Parse rattler authentication data into username/password tuple.
600
+
601
+ Handles rattler Authentication variants:
602
+ - {"BearerToken": "token"}
603
+ - {"CondaToken": "token"}
604
+ - {"BasicHTTP": {"username": "user", "password": "pass"}}
605
+
606
+ Returns:
607
+ Tuple of (username, password) or None if unknown auth type
608
+ """
609
+ if "BearerToken" in auth_data:
610
+ return (AUTH_BEARER_USERNAME, auth_data["BearerToken"])
611
+ elif "CondaToken" in auth_data:
612
+ return (CONDA_TOKEN_USERNAME, auth_data["CondaToken"])
613
+ elif "BasicHTTP" in auth_data:
614
+ basic_auth = auth_data["BasicHTTP"]
615
+ return (
616
+ basic_auth.get("username", ""),
617
+ basic_auth.get("password", ""),
618
+ )
619
+ else:
620
+ return None
621
+
622
+
623
+ @functools.lru_cache
624
+ def get_rattler_auth_dict(home_dir: Path | None = None) -> dict[str, tuple[str, str]]:
625
+ # RATTLER_AUTH_FILE is an env var that can override the default location
626
+ env_auth_file = os.environ.get("RATTLER_AUTH_FILE")
627
+ if env_auth_file:
628
+ auth_file = Path(env_auth_file)
629
+ else:
630
+ if home_dir is None:
631
+ home_dir = Path.home()
632
+ auth_file = home_dir / ".rattler" / "credentials.json"
633
+ domain_auth = {}
634
+ if auth_file.exists():
635
+ with auth_file.open("r") as f:
636
+ auth_data = json.load(f)
637
+ for domain, auth in auth_data.items():
638
+ parsed_auth = _parse_rattler_auth_data(auth)
639
+ if parsed_auth:
640
+ domain_auth[domain] = parsed_auth
641
+ else:
642
+ logger.debug(f"Encountered unknown rattler auth type {list(auth.keys())} for domain {domain}")
643
+ return domain_auth
644
+
645
+
646
+ def get_rattler_keyring_auth(netloc: str) -> tuple[str, str] | None:
647
+ """Returns the Requests tuple auth for a given domain from rattler keyring storage."""
648
+ if not HAVE_KEYRING:
649
+ logger.debug("keyring not available, skipping rattler keyring auth")
650
+ return None
651
+
652
+ def try_keyring_auth(host: str) -> tuple[str, str] | None:
653
+ """Try to get auth from keyring for a specific host using rattler's storage format."""
654
+ try:
655
+ # Use the existing get_keyring_auth function with "rattler" as the URL
656
+ # and the host as the username to get rattler-stored credentials
657
+ auth_parts = get_keyring_auth("rattler", host)
658
+ if auth_parts:
659
+ username, password = auth_parts
660
+ if password:
661
+ try:
662
+ auth_data = json.loads(password)
663
+ parsed_auth = _parse_rattler_auth_data(auth_data)
664
+ if parsed_auth:
665
+ return parsed_auth
666
+ except json.JSONDecodeError:
667
+ # If it's not JSON, treat it as a simple username/password
668
+ return (username or host, password)
669
+
670
+ except Exception as e:
671
+ logger.debug(f"Error getting rattler keyring auth for {host}: {e}")
672
+ return None
673
+
674
+ return None
675
+
676
+ # Try exact match first
677
+ auth_parts = try_keyring_auth(netloc)
678
+ if auth_parts:
679
+ logger.debug(f"Found rattler keyring auth for {netloc}")
680
+ return auth_parts
681
+
682
+ # Try parent domain matches if exact match failed
683
+ # If looking for foo.example.com, try example.com (but not com)
684
+ parts = netloc.split(".")
685
+ for i in range(1, len(parts) - 1): # Stop before single TLD
686
+ parent_domain = ".".join(parts[i:])
687
+
688
+ auth_parts = try_keyring_auth(parent_domain)
689
+ if auth_parts:
690
+ logger.debug(f"Found rattler keyring auth for {parent_domain} (matching {netloc})")
691
+ return auth_parts
692
+
693
+ logger.debug(f"No rattler keyring auth found for {netloc}")
694
+ return None
695
+
696
+
697
+ def get_rattler_auth(netloc: str) -> tuple[str, str] | None:
698
+ """Returns the Requests tuple auth for a given domain from rattler keyring or auth file."""
699
+ # Try keyring first (primary storage method for rattler/pixi)
700
+ auth_parts = get_rattler_keyring_auth(netloc)
701
+ if auth_parts:
702
+ return auth_parts
703
+
704
+ # Fall back to file-based storage
705
+ # rattler allows wildcards, so we have to check for exact matches first
706
+ auth_parts = get_rattler_auth_dict().get(netloc, None)
707
+ if auth_parts:
708
+ return auth_parts
709
+
710
+ # then check for wildcard matches in file storage
711
+ for domain, auth in get_rattler_auth_dict().items():
712
+ if domain.startswith("*.") and netloc.endswith(domain[1:]):
713
+ return auth
714
+
715
+ return None
716
+
717
+
598
718
  @functools.lru_cache
599
719
  def get_conda_config() -> dict:
600
720
  """Returns the current conda config as dictionary"""
@@ -746,6 +866,7 @@ def set_auth_for_url(url: Url | str) -> str:
746
866
  use_keyring = dask.config.get("coiled.package_sync.conda.cred_sources.keyring", True)
747
867
  use_conda_auth = dask.config.get("coiled.package_sync.conda.cred_sources.conda", True)
748
868
  use_mamba_auth = dask.config.get("coiled.package_sync.conda.cred_sources.mamba", True)
869
+ use_rattler_auth = dask.config.get("coiled.package_sync.conda.cred_sources.rattler", True)
749
870
 
750
871
  no_auth_url = parsed_url._replace(auth=None).url
751
872
  auth_parts = (
@@ -759,6 +880,8 @@ def set_auth_for_url(url: Url | str) -> str:
759
880
  or (get_conda_auth(no_auth_url) if use_conda_auth else None)
760
881
  # mamba could have URL stored by netloc/path or netloc
761
882
  or ((get_mamba_auth(f"{netloc}{path}") or get_mamba_auth(netloc)) if use_mamba_auth else None)
883
+ # rattler/pixi stores URL stored by netloc in keyring or a fallback file
884
+ or (get_rattler_auth(netloc) if use_rattler_auth else None)
762
885
  )
763
886
  if auth_parts is not None:
764
887
  username, password = auth_parts
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coiled
3
- Version: 1.121.1.dev19
3
+ Version: 1.121.1.dev20
4
4
  Summary: Python client for coiled.io dask clusters
5
5
  Project-URL: Homepage, https://coiled.io
6
6
  Maintainer-email: Coiled <info@coiled.io>
@@ -19,7 +19,7 @@ coiled/prefect.py,sha256=j1EOg7Xuw82TNRonAGEoZ3ANlwN8GM5aDXRYSjC0lnA,1497
19
19
  coiled/pypi_conda_map.py,sha256=GlLqvSjqvFoEPsoIVZ7so4JH3j-Z9oHKwf77UoQ7d7s,9865
20
20
  coiled/scan.py,sha256=ghAo7TKAG7E013HJpYWbic-Kp_UUf8iu533GaBpYnS8,25760
21
21
  coiled/software.py,sha256=eh3kZ8QBuIt_SPvTy_x6TXEv87SGqOJkO4HW-LCSsas,8701
22
- coiled/software_utils.py,sha256=6fdhzNG09XZuagOBaqAaqYZRNdh8TGt3XA3ULbdfWQ8,35503
22
+ coiled/software_utils.py,sha256=JqGO8nstm0Hi-UCIBhHa25reNeVO-XOnv5eLoIyRcBo,40367
23
23
  coiled/spans.py,sha256=Aq2MOX6JXaJ72XiEmymPcsefs-kID85MEw6t-kOdPWI,2078
24
24
  coiled/spark.py,sha256=kooZCZT4dLMG_AQEOlaf6gj86G3UdowDfbw-Eiq94MU,9059
25
25
  coiled/types.py,sha256=G2SAprLouhf5GpoO3KnSxRlBtUP7_cI4xc7xQK_6bfE,13873
@@ -94,8 +94,8 @@ coiled/v2/widgets/__init__.py,sha256=Bt3GHTTyri-kFUaqGRVydDM-sCg5NdNujDg2RyvgV8U
94
94
  coiled/v2/widgets/interface.py,sha256=YeMQ5qdRbbpM04x9qIg2LE1xwxyRxFbdDYnkrwHazPk,301
95
95
  coiled/v2/widgets/rich.py,sha256=3rU5-yso92NdeEh3uSvEE-GwPNyp6i0Nb5PE5czXCik,28974
96
96
  coiled/v2/widgets/util.py,sha256=Y8qpGqwNzqfCzgyRFRy7vcscBoXqop-Upi4HLPpXLgg,3120
97
- coiled-1.121.1.dev19.dist-info/METADATA,sha256=_ZXP96o4xvzB3c-FJU2QT08ItClCHyqhLjMyU9QbSn4,2182
98
- coiled-1.121.1.dev19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
99
- coiled-1.121.1.dev19.dist-info/entry_points.txt,sha256=C8dz1ST_bTlTO-kNvuHBJQma9PyJPotg0S4xpPt5aHY,47
100
- coiled-1.121.1.dev19.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
101
- coiled-1.121.1.dev19.dist-info/RECORD,,
97
+ coiled-1.121.1.dev20.dist-info/METADATA,sha256=X_pHRay_8labUlOjLQdOPufh6tJuF-X_F2iAeh7KccY,2182
98
+ coiled-1.121.1.dev20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
99
+ coiled-1.121.1.dev20.dist-info/entry_points.txt,sha256=C8dz1ST_bTlTO-kNvuHBJQma9PyJPotg0S4xpPt5aHY,47
100
+ coiled-1.121.1.dev20.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
101
+ coiled-1.121.1.dev20.dist-info/RECORD,,