kumoai 2.13.0.dev202512040651__cp312-cp312-win_amd64.whl → 2.14.0.dev202512111731__cp312-cp312-win_amd64.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.
@@ -10,7 +10,7 @@ from kumoapi.table import TableDefinition
10
10
  from kumoapi.typing import Stype
11
11
  from typing_extensions import Self
12
12
 
13
- from kumoai import in_notebook
13
+ from kumoai import in_notebook, in_snowflake_notebook
14
14
  from kumoai.experimental.rfm.base import Column, SourceColumn, SourceForeignKey
15
15
  from kumoai.experimental.rfm.infer import (
16
16
  contains_categorical,
@@ -384,7 +384,12 @@ class Table(ABC):
384
384
  if self._num_rows is not None:
385
385
  num_rows_repr = ' ({self._num_rows:,} rows)'
386
386
 
387
- if in_notebook():
387
+ if in_snowflake_notebook():
388
+ import streamlit as st
389
+ md_repr = f"### 🏷️ Metadata of Table `{self.name}`{num_rows_repr}"
390
+ st.markdown(md_repr)
391
+ st.dataframe(self.metadata, hide_index=True)
392
+ elif in_notebook():
388
393
  from IPython.display import Markdown, display
389
394
  md_repr = f"### 🏷️ Metadata of Table `{self.name}`{num_rows_repr}"
390
395
  display(Markdown(md_repr))
@@ -496,7 +501,7 @@ class Table(ABC):
496
501
  f' end_time_column={self._end_time_column},\n'
497
502
  f')')
498
503
 
499
- # Abstract method #########################################################
504
+ # Abstract Methods ########################################################
500
505
 
501
506
  @cached_property
502
507
  def _source_column_dict(self) -> Dict[str, SourceColumn]:
@@ -3,7 +3,6 @@ import io
3
3
  import warnings
4
4
  from collections import defaultdict
5
5
  from dataclasses import dataclass, field
6
- from importlib.util import find_spec
7
6
  from pathlib import Path
8
7
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union
9
8
 
@@ -13,7 +12,7 @@ from kumoapi.table import TableDefinition
13
12
  from kumoapi.typing import Stype
14
13
  from typing_extensions import Self
15
14
 
16
- from kumoai import in_notebook
15
+ from kumoai import in_notebook, in_snowflake_notebook
17
16
  from kumoai.experimental.rfm import Table
18
17
  from kumoai.graph import Edge
19
18
  from kumoai.mixin import CastMixin
@@ -502,9 +501,13 @@ class Graph:
502
501
 
503
502
  def print_metadata(self) -> None:
504
503
  r"""Prints the :meth:`~Graph.metadata` of the graph."""
505
- if in_notebook():
504
+ if in_snowflake_notebook():
505
+ import streamlit as st
506
+ st.markdown("### 🗂️ Graph Metadata")
507
+ st.dataframe(self.metadata, hide_index=True)
508
+ elif in_notebook():
506
509
  from IPython.display import Markdown, display
507
- display(Markdown('### 🗂️ Graph Metadata'))
510
+ display(Markdown("### 🗂️ Graph Metadata"))
508
511
  df = self.metadata
509
512
  try:
510
513
  if hasattr(df.style, 'hide'):
@@ -548,26 +551,36 @@ class Graph:
548
551
  edge.src_table, edge.fkey) for edge in self.edges]
549
552
  edges = sorted(edges)
550
553
 
551
- if in_notebook():
554
+ if in_snowflake_notebook():
555
+ import streamlit as st
556
+ st.markdown("### 🕸️ Graph Links (FK ↔️ PK)")
557
+ if len(edges) > 0:
558
+ st.markdown('\n'.join([
559
+ f"- `{edge[2]}.{edge[3]}` ↔️ `{edge[0]}.{edge[1]}`"
560
+ for edge in edges
561
+ ]))
562
+ else:
563
+ st.markdown("*No links registered*")
564
+ elif in_notebook():
552
565
  from IPython.display import Markdown, display
553
- display(Markdown('### 🕸️ Graph Links (FK ↔️ PK)'))
566
+ display(Markdown("### 🕸️ Graph Links (FK ↔️ PK)"))
554
567
  if len(edges) > 0:
555
568
  display(
556
569
  Markdown('\n'.join([
557
- f'- `{edge[2]}.{edge[3]}` ↔️ `{edge[0]}.{edge[1]}`'
570
+ f"- `{edge[2]}.{edge[3]}` ↔️ `{edge[0]}.{edge[1]}`"
558
571
  for edge in edges
559
572
  ])))
560
573
  else:
561
- display(Markdown('*No links registered*'))
574
+ display(Markdown("*No links registered*"))
562
575
  else:
563
576
  print("🕸️ Graph Links (FK ↔️ PK):")
564
577
  if len(edges) > 0:
565
578
  print('\n'.join([
566
- f'• {edge[2]}.{edge[3]} ↔️ {edge[0]}.{edge[1]}'
579
+ f"• {edge[2]}.{edge[3]} ↔️ {edge[0]}.{edge[1]}"
567
580
  for edge in edges
568
581
  ]))
569
582
  else:
570
- print('No links registered')
583
+ print("No links registered")
571
584
 
572
585
  def link(
573
586
  self,
@@ -884,19 +897,19 @@ class Graph:
884
897
 
885
898
  return True
886
899
 
887
- # Check basic dependency:
888
- if not find_spec('graphviz'):
889
- raise ModuleNotFoundError("The 'graphviz' package is required for "
890
- "visualization")
891
- elif not has_graphviz_executables():
900
+ try: # Check basic dependency:
901
+ import graphviz
902
+ except ImportError as e:
903
+ raise ImportError("The 'graphviz' package is required for "
904
+ "visualization") from e
905
+
906
+ if not in_snowflake_notebook() and not has_graphviz_executables():
892
907
  raise RuntimeError("Could not visualize graph as 'graphviz' "
893
908
  "executables are not installed. These "
894
909
  "dependencies are required in addition to the "
895
910
  "'graphviz' Python package. Please install "
896
911
  "them as described at "
897
912
  "https://graphviz.org/download/.")
898
- else:
899
- import graphviz
900
913
 
901
914
  format: Optional[str] = None
902
915
  if isinstance(path, str):
@@ -980,6 +993,9 @@ class Graph:
980
993
  graph.render(path, cleanup=True)
981
994
  elif isinstance(path, io.BytesIO):
982
995
  path.write(graph.pipe())
996
+ elif in_snowflake_notebook():
997
+ import streamlit as st
998
+ st.graphviz_chart(graph)
983
999
  elif in_notebook():
984
1000
  from IPython.display import display
985
1001
  display(graph)
@@ -134,7 +134,7 @@ class PQueryPandasExecutor(PQueryExecutor[pd.DataFrame, pd.Series,
134
134
  outs: List[pd.Series] = []
135
135
  masks: List[np.ndarray] = []
136
136
  for _ in range(num_forecasts):
137
- anchor_target_time = anchor_time[target_batch]
137
+ anchor_target_time = anchor_time.iloc[target_batch]
138
138
  anchor_target_time = anchor_target_time.reset_index(drop=True)
139
139
 
140
140
  time_filter_mask = (target_time <= anchor_target_time +