Skip to content

Commit

Permalink
- SAND CLI can import dataset returned from a python function
Browse files Browse the repository at this point in the history
- SAND CLI create project command does not require project's description (default to use dataset name)
  • Loading branch information
Binh Vu committed Apr 13, 2024
1 parent 0c540ca commit 145a713
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Changelog

## [4.1.0] - 2024-04-13

### Added

- SAND CLI can import dataset returned from a python function

### Changed

- SAND CLI create project command does not require project's description (default to use dataset name)

## [Unreleased](https://github.com/usc-isi-i2/sand/tree/HEAD)

[Full Changelog](https://github.com/usc-isi-i2/sand/compare/2.1.5...HEAD)

**Changed**
### Changed

- Update dependency: `d-repr` version constraint to `^2.10.0` from prerelease version.
- Update dockerfile and add docker-compose example.
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tool.poetry]
name = "web-sand"
version = "4.0.2"
version = "4.1.0"
description = "UI for browsing/editing semantic descriptions"
authors = ["Binh Vu <binh@toan2.com>"]
repository = "https://github.com/usc-isi-i2/sand"
license = "MIT"
packages = [{ include = "sand" }]
readme = "README.md"
include = ["sand/www/**/*"]
# include = ["sand/www/**/*"]

[tool.poetry.scripts]
sand = 'sand.__main__:cli'
Expand Down
6 changes: 3 additions & 3 deletions sand/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ def start(

@click.command()
@click.option("-d", "--db", required=True, help="sand database file")
@click.option("--description", required=True, help="Description of the project")
@click.option("--description", help="Description of the project")
@click.argument("name")
def create(db, description: str, name: str):
def create(db, description: Optional[str], name: str):
"""Create project if not exist"""
init_db(db)
Project(name=name, description=description).save()
Project(name=name, description=description or name).save()


@click.command(help="Remove a project")
Expand Down
13 changes: 11 additions & 2 deletions sand/commands/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import click
from sm.dataset import Dataset, Example, FullTable
from sm.misc.funcs import import_func
from sm.outputs.semantic_model import DataNode
from tqdm.auto import tqdm

Expand All @@ -22,7 +23,11 @@
@click.command(name="load")
@click.option("-d", "--db", required=True, help="smc database file")
@click.option("-p", "--project", default="default", help="Project name")
@click.option("--dataset", required=True, help="Path to tables")
@click.option(
"--dataset",
required=True,
help="Path to tables or a python function that returns the dataset in the following format: <python_func>::<dataset_name>",
)
@click.option(
"-n",
"--n-tables",
Expand All @@ -34,7 +39,11 @@ def load_dataset(db: str, project: str, dataset: str, n_tables: int):
"""Load a dataset into a project"""
init_db(db)

examples = Dataset(Path(dataset)).load()
if dataset.find("::") != -1:
func, dsquery = dataset.split("::")
examples = import_func(func)(dsquery).load()
else:
examples = Dataset(Path(dataset)).load()

if n_tables > 0:
examples = examples[:n_tables]
Expand Down
Empty file added sand_scripts/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions sand_scripts/predefined_datasets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from sm_datasets.datasets import Datasets


def load(dataset: str):
return Datasets().get_dataset(dataset)

0 comments on commit 145a713

Please sign in to comment.