Skip to content

Commit 4ec8b05

Browse files
committed
improve index storage, fix index receiving logic
1 parent b3607f3 commit 4ec8b05

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "planetarypy"
7-
version = "0.2.0"
7+
version = "0.2.1"
88
description = "Core package for planetary data tools. Includes PDS index utilities, SPICE integrations, and more."
99
readme = "README.md"
1010
requires-python = ">= 3.9, <4"
@@ -116,4 +116,4 @@ extend-ignore = ["E203", "E701"]
116116
[tool.bumpversion]
117117
current_version = "0.2.0"
118118
commit = true
119-
tag = true
119+
tag = true

src/planetarypy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__author__ = """PlanetaryPy Developers"""
44
__email__ = "kmichael.aye@gmail.com"
5-
__version__ = "0.2.0"
5+
__version__ = "0.2.1"

src/planetarypy/pds/__init__.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@
77
from .index_config import access_log, urls_config
88
from .index_labels import IndexLabel
99
from .indexes import Index
10-
from .utils import (
11-
get_index,
12-
list_indexes,
13-
list_instruments,
14-
list_missions,
15-
print_pds_tree,
16-
)
10+
from .utils import *
1711

1812
__all__ = [
1913
"Index",
@@ -23,6 +17,6 @@
2317
"list_missions",
2418
"list_instruments",
2519
"list_indexes",
26-
"print_pds_tree",
20+
"list_available_indexes",
2721
"get_index",
2822
]

src/planetarypy/pds/indexes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ def table_url(self):
132132

133133
@property
134134
def local_dir(self):
135-
p = storage_root / str(self.key).replace(".", "/")
135+
# squeeze in an indexes subfolder
136+
key_path = Path(str(self.key).replace(".", "/"))
137+
indexes_path = key_path.parent / Path("indexes") / key_path.name
138+
p = storage_root / indexes_path
136139
p.mkdir(parents=True, exist_ok=True)
137140
return p
138141

src/planetarypy/pds/utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"list_missions",
88
"list_instruments",
99
"list_indexes",
10-
"print_pds_tree",
10+
"list_available_indexes",
1111
"get_index",
1212
]
1313

1414
from typing import Optional
1515

1616
import pandas as pd
1717

18-
from .indexes import Index
18+
from planetarypy.pds.indexes import Index
1919

2020

2121
def list_missions() -> list[str]:
@@ -116,7 +116,7 @@ def list_indexes(mission_instrument: str) -> list[str]:
116116
return sorted(indexes)
117117

118118

119-
def print_pds_tree(
119+
def list_available_indexes(
120120
filter_mission: Optional[str] = None, filter_instrument: Optional[str] = None
121121
) -> None:
122122
"""Print an ASCII tree diagram of all missions, instruments, and indexes.
@@ -226,8 +226,9 @@ def get_index(
226226
>>> df = get_index('mro.ctx.edr')
227227
"""
228228
index = Index(dotted_index_key)
229+
if not index.local_label_path.is_file():
230+
index.download()
229231
# only do time-consuming update check if refresh is True
230-
if refresh:
231-
if index.update_available:
232-
index.download()
232+
if (refresh and index.update_available) or force:
233+
index.download()
233234
return index.parquet

0 commit comments

Comments
 (0)