Skip to content

Commit db4a215

Browse files
committed
Add ds.publications module for searching and accessing published datasets
- New publications.py: list_publications, search_publications, get_publication, list_publication_files - ds.publications.search() for client-side keyword/PI/title search - Files accessed via designsafe.storage.published Tapis system - Add docs/publications.md, update nav and examples sidebar - Add tests (11 new, 153 total passing) - Add examples/publications.ipynb with working outputs
1 parent 6898e54 commit db4a215

9 files changed

Lines changed: 1357 additions & 0 deletions

File tree

dapi/client.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from . import systems as systems_module
88
from . import launcher as launcher_module
99
from . import projects as projects_module
10+
from . import publications as publications_module
1011
from .db.accessor import DatabaseAccessor
1112

1213
# Import only the necessary classes/functions from jobs
@@ -33,6 +34,7 @@ class DSClient:
3334
files (FileMethods): Interface for file operations (upload, download, list).
3435
jobs (JobMethods): Interface for job submission and monitoring.
3536
projects (ProjectMethods): Interface for DesignSafe project management.
37+
publications (PublicationMethods): Interface for published datasets.
3638
systems (SystemMethods): Interface for system information and queues.
3739
db (DatabaseAccessor): Interface for database connections and queries.
3840
@@ -93,6 +95,7 @@ def __init__(self, tapis_client: Optional[Tapis] = None, **auth_kwargs):
9395
self.files = FileMethods(self.tapis)
9496
self.jobs = JobMethods(self.tapis)
9597
self.projects = ProjectMethods(self.tapis)
98+
self.publications = PublicationMethods(self.tapis)
9699
self.systems = SystemMethods(self.tapis)
97100
self.db = DatabaseAccessor()
98101

@@ -327,6 +330,93 @@ def files(
327330
)
328331

329332

333+
class PublicationMethods:
334+
"""Interface for DesignSafe published datasets.
335+
336+
Provides methods for listing, searching, and inspecting published datasets
337+
and their files on DesignSafe.
338+
339+
Args:
340+
tapis_client (Tapis): Authenticated Tapis client instance.
341+
"""
342+
343+
def __init__(self, tapis_client: Tapis):
344+
self._tapis = tapis_client
345+
346+
def list(self, limit: int = 100, offset: int = 0, output: str = "df"):
347+
"""List published datasets on DesignSafe.
348+
349+
Args:
350+
limit (int, optional): Maximum publications to return. Defaults to 100.
351+
offset (int, optional): Number to skip. Defaults to 0.
352+
output (str, optional): "df" for DataFrame (default), "list" for dicts.
353+
354+
Returns:
355+
DataFrame or List[Dict]: Publications with projectId, title, pi, type, keywords, created.
356+
357+
Example:
358+
>>> ds.publications.list()
359+
"""
360+
return publications_module.list_publications(
361+
self._tapis, limit=limit, offset=offset, output=output
362+
)
363+
364+
def search(self, query: str, limit: int = 100, output: str = "df"):
365+
"""Search published datasets by keyword, title, or PI name.
366+
367+
Args:
368+
query (str): Search term (case-insensitive).
369+
limit (int, optional): Max publications to fetch before filtering. Defaults to 100.
370+
output (str, optional): "df" for DataFrame (default), "list" for dicts.
371+
372+
Returns:
373+
DataFrame or List[Dict]: Matching publications.
374+
375+
Example:
376+
>>> ds.publications.search("liquefaction")
377+
>>> ds.publications.search("lateral spreading", limit=500)
378+
"""
379+
return publications_module.search_publications(
380+
self._tapis, query, limit=limit, output=output
381+
)
382+
383+
def get(self, project_id: str) -> Dict:
384+
"""Get detailed metadata for a published dataset.
385+
386+
Args:
387+
project_id (str): Project ID (e.g., "PRJ-1271").
388+
389+
Returns:
390+
Dict: Publication metadata including title, description, DOIs, keywords, PI.
391+
392+
Example:
393+
>>> info = ds.publications.get("PRJ-6270")
394+
>>> print(info["dois"])
395+
"""
396+
return publications_module.get_publication(self._tapis, project_id)
397+
398+
def files(
399+
self, project_id: str, path: str = "/", limit: int = 100, output: str = "df"
400+
):
401+
"""List files in a published dataset.
402+
403+
Args:
404+
project_id (str): Project ID (e.g., "PRJ-1271").
405+
path (str, optional): Path within the publication. Defaults to "/".
406+
limit (int, optional): Max items to return. Defaults to 100.
407+
output (str, optional): "df" for DataFrame (default), "raw" for Tapis objects.
408+
409+
Returns:
410+
DataFrame or List: Files with name, type, size, lastModified, path.
411+
412+
Example:
413+
>>> ds.publications.files("PRJ-1271")
414+
"""
415+
return publications_module.list_publication_files(
416+
self._tapis, project_id, path=path, limit=limit, output=output
417+
)
418+
419+
330420
class SystemMethods:
331421
"""Interface for Tapis system information and queue management.
332422

0 commit comments

Comments
 (0)