featrixsphere 0.2.1206__py3-none-any.whl → 0.2.1221__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.
featrixsphere/__init__.py CHANGED
@@ -38,7 +38,7 @@ Example:
38
38
  ... labels=['Experiment A', 'Experiment B'])
39
39
  """
40
40
 
41
- __version__ = "0.2.1206"
41
+ __version__ = "0.2.1221"
42
42
  __author__ = "Featrix"
43
43
  __email__ = "support@featrix.com"
44
44
  __license__ = "MIT"
featrixsphere/client.py CHANGED
@@ -633,13 +633,97 @@ class FeatrixSphereClient:
633
633
  _client=self
634
634
  )
635
635
 
636
- def get_model_card(self, session_id: str, max_retries: int = None) -> Dict[str, Any]:
636
+ def update_user_metadata(self, session_id: str, metadata: Dict[str, Any], write_mode: str = "merge") -> Dict[str, Any]:
637
+ """
638
+ Update user metadata for a session.
639
+
640
+ Args:
641
+ session_id: The session ID to update metadata for
642
+ metadata: Dictionary of metadata to update (max 32KB total)
643
+ write_mode: How to update metadata:
644
+ - "merge" (default): Merge new metadata with existing (existing keys are updated, new keys are added)
645
+ - "overwrite": Replace all user_metadata with the new dictionary
646
+
647
+ Returns:
648
+ Dictionary containing the updated session information
649
+
650
+ Raises:
651
+ requests.exceptions.HTTPError: If the request fails
652
+ ValueError: If write_mode is not "merge" or "overwrite"
653
+
654
+ Example:
655
+ >>> # Merge new metadata with existing
656
+ >>> client.update_user_metadata(
657
+ ... session_id="abc123",
658
+ ... metadata={"new_key": "value", "existing_key": "updated_value"},
659
+ ... write_mode="merge"
660
+ ... )
661
+
662
+ >>> # Replace all metadata
663
+ >>> client.update_user_metadata(
664
+ ... session_id="abc123",
665
+ ... metadata={"only_key": "only_value"},
666
+ ... write_mode="overwrite"
667
+ ... )
668
+ """
669
+ if write_mode not in ["merge", "overwrite"]:
670
+ raise ValueError(f"write_mode must be 'merge' or 'overwrite', got '{write_mode}'")
671
+
672
+ request_data = {
673
+ "user_metadata": metadata,
674
+ "write_mode": write_mode
675
+ }
676
+
677
+ response_data = self._post_json(f"/session/{session_id}/update_user_metadata", request_data)
678
+ return response_data
679
+
680
+ def is_foundation_model_ready(self, session_id: str, max_retries: int = None) -> Tuple[bool, str]:
681
+ """
682
+ Check if a foundation model session is ready to use (training completed).
683
+
684
+ Args:
685
+ session_id: The session ID to check
686
+ max_retries: Maximum number of retries (defaults to client default)
687
+
688
+ Returns:
689
+ Tuple of (is_ready: bool, status_message: str)
690
+ - is_ready: True if session is done and model card is available
691
+ - status_message: Human-readable status message
692
+
693
+ Example:
694
+ >>> is_ready, message = client.is_foundation_model_ready("session_123")
695
+ >>> if not is_ready:
696
+ ... print(f"Foundation model not ready: {message}")
697
+ """
698
+ try:
699
+ session_status = self.get_session_status(session_id, max_retries=max_retries)
700
+
701
+ if session_status.status in ["done", "DONE"]:
702
+ # Check if model card exists
703
+ try:
704
+ self.get_model_card(session_id, max_retries=max_retries, check_status_first=False)
705
+ return True, "Foundation model is ready"
706
+ except (requests.exceptions.HTTPError, FileNotFoundError):
707
+ return False, "Session is done but model card is not available yet"
708
+ else:
709
+ return False, f"Session is still {session_status.status}. Training may still be in progress."
710
+
711
+ except requests.exceptions.HTTPError as e:
712
+ if e.response.status_code == 404:
713
+ return False, f"Session {session_id} not found"
714
+ return False, f"Error checking session status: {e}"
715
+ except Exception as e:
716
+ return False, f"Error checking foundation model: {e}"
717
+
718
+ def get_model_card(self, session_id: str, max_retries: int = None, check_status_first: bool = True) -> Dict[str, Any]:
637
719
  """
638
720
  Get the model card JSON for a given session.
639
721
 
640
722
  Args:
641
723
  session_id: The session ID to get the model card for
642
724
  max_retries: Maximum number of retries (defaults to client default)
725
+ check_status_first: If True, check session status before fetching model card.
726
+ Provides better error messages if session is still training.
643
727
 
644
728
  Returns:
645
729
  Dictionary containing the model card JSON data
@@ -647,12 +731,31 @@ class FeatrixSphereClient:
647
731
  Raises:
648
732
  requests.exceptions.HTTPError: If the request fails
649
733
  FileNotFoundError: If the model card doesn't exist (404)
734
+ ValueError: If session is not ready and check_status_first is True
650
735
 
651
736
  Example:
652
737
  >>> client = FeatrixSphereClient()
653
738
  >>> model_card = client.get_model_card("session_123")
654
739
  >>> print(model_card["model_details"]["name"])
655
740
  """
741
+ # Check session status first to provide better error messages
742
+ if check_status_first:
743
+ try:
744
+ session_status = self.get_session_status(session_id, max_retries=max_retries)
745
+ if session_status.status not in ["done", "DONE"]:
746
+ raise ValueError(
747
+ f"Session {session_id} is not ready (status: {session_status.status}). "
748
+ f"Model card is only available after training completes. "
749
+ f"Use wait_for_session_completion() to wait for training to finish."
750
+ )
751
+ except requests.exceptions.HTTPError as e:
752
+ # If we can't get status, continue and let the model_card request fail
753
+ # This handles cases where the session doesn't exist
754
+ if e.response.status_code == 404:
755
+ raise FileNotFoundError(f"Session {session_id} not found") from e
756
+ # For other HTTP errors, continue to try model_card request
757
+ pass
758
+
656
759
  response = self._make_request(
657
760
  "GET",
658
761
  f"/session/{session_id}/model_card",
@@ -774,8 +877,8 @@ class FeatrixSphereClient:
774
877
  >>> print(f"Model card recreated: {model_card['model_info']['name']}")
775
878
  """
776
879
  response = self._make_request(
777
- "POST",
778
- f"/session/{session_id}/model_card",
880
+ "GET",
881
+ f"/compute/session/{session_id}/model_card",
779
882
  max_retries=max_retries
780
883
  )
781
884
  return response.json()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: featrixsphere
3
- Version: 0.2.1206
3
+ Version: 0.2.1221
4
4
  Summary: Transform any CSV into a production-ready ML model in minutes, not months.
5
5
  Home-page: https://github.com/Featrix/sphere
6
6
  Author: Featrix
@@ -0,0 +1,9 @@
1
+ featrixsphere/__init__.py,sha256=P6lNvrcNRFDLvHiBlcFeM-UTp0SymQm5msQQHX6W8XU,1888
2
+ featrixsphere/cli.py,sha256=AW9O3vCvCNJ2UxVGN66eRmeN7XLSiHJlvK6JLZ9UJXc,13358
3
+ featrixsphere/client.py,sha256=lwPu6RQVA5zps9DTYrVlPhRv8_8PEdFGI11hezLSEyA,379068
4
+ featrixsphere/test_client.py,sha256=4SiRbib0ms3poK0UpnUv4G0HFQSzidF3Iswo_J2cjLk,11981
5
+ featrixsphere-0.2.1221.dist-info/METADATA,sha256=k8SrUaI9oa3JaTObnLVQGMA-iyoZM7wLdWnzluqh-Ms,16232
6
+ featrixsphere-0.2.1221.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ featrixsphere-0.2.1221.dist-info/entry_points.txt,sha256=QreJeYfD_VWvbEqPmMXZ3pqqlFlJ1qZb-NtqnyhEldc,51
8
+ featrixsphere-0.2.1221.dist-info/top_level.txt,sha256=AyN4wjfzlD0hWnDieuEHX0KckphIk_aC73XCG4df5uU,14
9
+ featrixsphere-0.2.1221.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- featrixsphere/__init__.py,sha256=6sjz6sAZEsBAotAiefePXdOHnoBmovpFqVy4vq4wONE,1888
2
- featrixsphere/cli.py,sha256=AW9O3vCvCNJ2UxVGN66eRmeN7XLSiHJlvK6JLZ9UJXc,13358
3
- featrixsphere/client.py,sha256=C9b_x2aRrGJJI0UCN2GtAdoSjIsMzAR9EKGbJvAzzPE,374039
4
- featrixsphere/test_client.py,sha256=4SiRbib0ms3poK0UpnUv4G0HFQSzidF3Iswo_J2cjLk,11981
5
- featrixsphere-0.2.1206.dist-info/METADATA,sha256=SjuRakp3SS59KnY4N7r65ZnlLp7Lg0O1DAq_NgQZ1fo,16232
6
- featrixsphere-0.2.1206.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- featrixsphere-0.2.1206.dist-info/entry_points.txt,sha256=QreJeYfD_VWvbEqPmMXZ3pqqlFlJ1qZb-NtqnyhEldc,51
8
- featrixsphere-0.2.1206.dist-info/top_level.txt,sha256=AyN4wjfzlD0hWnDieuEHX0KckphIk_aC73XCG4df5uU,14
9
- featrixsphere-0.2.1206.dist-info/RECORD,,