spells-mtg 0.10.9__tar.gz → 0.10.11__tar.gz

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 spells-mtg might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spells-mtg
3
- Version: 0.10.9
3
+ Version: 0.10.11
4
4
  Summary: analaysis of 17Lands.com public datasets
5
5
  Author-Email: Joel Barnes <oelarnes@gmail.com>
6
6
  License: MIT
@@ -11,7 +11,7 @@ dependencies = [
11
11
  ]
12
12
  requires-python = ">=3.11"
13
13
  readme = "README.md"
14
- version = "0.10.9"
14
+ version = "0.10.11"
15
15
 
16
16
  [project.license]
17
17
  text = "MIT"
@@ -9,7 +9,9 @@ Caches are cleared per-set when new files are downloaded.
9
9
 
10
10
  from enum import StrEnum
11
11
  import os
12
+ from pathlib import Path
12
13
  import sys
14
+
13
15
  import polars as pl
14
16
 
15
17
 
@@ -70,6 +72,25 @@ def data_home() -> str:
70
72
  )
71
73
 
72
74
 
75
+ def ad_hoc_dir():
76
+ ad_hoc_dir = Path(data_home()) / "ad_hoc"
77
+ if not os.path.isdir(ad_hoc_dir):
78
+ os.makedirs(ad_hoc_dir)
79
+ return ad_hoc_dir
80
+
81
+
82
+ def save_ad_hoc_dataset(df: pl.DataFrame, key: str):
83
+ df.write_parquet(ad_hoc_dir() / f"{key}.parquet")
84
+
85
+
86
+ def read_ad_hoc_dataset(key: str):
87
+ path = ad_hoc_dir() / f"{key}.parquet"
88
+ if os.path.exists(path):
89
+ return pl.read_parquet(ad_hoc_dir() / f"{key}.parquet")
90
+ else:
91
+ return None
92
+
93
+
73
94
  def create_test_data(set_code: str, test_num_drafts: int = 100):
74
95
  """
75
96
  run from prod environment to write test data for `set_code` into
@@ -1,4 +1,5 @@
1
1
  all_sets = [
2
+ "TDM",
2
3
  "DFT",
3
4
  "PIO",
4
5
  "FDN",
@@ -19,7 +19,7 @@ from polars.exceptions import ColumnNotFoundError
19
19
 
20
20
  from spells import cache
21
21
  import spells.filter
22
- import spells.manifest
22
+ from spells import manifest
23
23
  from spells.columns import ColDef, ColSpec, get_specs
24
24
  from spells.enums import View, ColName, ColType
25
25
  from spells.log import make_verbose
@@ -379,7 +379,7 @@ def _fetch_or_cache(
379
379
 
380
380
  def _base_agg_df(
381
381
  set_code: str,
382
- m: spells.manifest.Manifest,
382
+ m: manifest.Manifest,
383
383
  use_streaming: bool = True,
384
384
  ) -> pl.DataFrame:
385
385
  join_dfs = []
@@ -516,7 +516,7 @@ def summon(
516
516
  this_set_context = None
517
517
 
518
518
  col_def_map = _hydrate_col_defs(code, specs, set_card_context, this_set_context)
519
- m = spells.manifest.create(col_def_map, columns, group_by, filter_spec)
519
+ m = manifest.create(col_def_map, columns, group_by, filter_spec)
520
520
 
521
521
  calc_fn = functools.partial(_base_agg_df, code, m, use_streaming=use_streaming)
522
522
  agg_df = _fetch_or_cache(
@@ -1,9 +1,8 @@
1
1
  from dataclasses import dataclass
2
2
 
3
- import spells.columns
4
- import spells.filter
3
+ import spells.filter as spells_filter
5
4
  from spells.enums import View, ColName, ColType
6
- from spells.columns import ColDef
5
+ from spells.columns import ColDef, default_columns
7
6
 
8
7
 
9
8
  @dataclass(frozen=True)
@@ -13,7 +12,7 @@ class Manifest:
13
12
  base_view_group_by: frozenset[str]
14
13
  view_cols: dict[View, frozenset[str]]
15
14
  group_by: tuple[str, ...]
16
- filter: spells.filter.Filter | None
15
+ filter: spells_filter.Filter | None
17
16
 
18
17
  def __post_init__(self):
19
18
  # No name filter check
@@ -166,7 +165,7 @@ def create(
166
165
  gbs = (ColName.NAME,) if group_by is None else tuple(group_by)
167
166
 
168
167
  if columns is None:
169
- cols = tuple(spells.columns.default_columns)
168
+ cols = tuple(default_columns)
170
169
  if ColName.NAME not in gbs:
171
170
  cols = tuple(
172
171
  col for col in cols if col not in (ColName.COLOR, ColName.RARITY)
@@ -174,7 +173,7 @@ def create(
174
173
  else:
175
174
  cols = tuple(columns)
176
175
 
177
- m_filter = spells.filter.from_spec(filter_spec)
176
+ m_filter = spells_filter.from_spec(filter_spec)
178
177
 
179
178
  col_set = frozenset(cols)
180
179
  col_set = col_set.union(frozenset(gbs) - {ColName.NAME})
File without changes
File without changes
File without changes