Skip to content

Commit

Permalink
resolve #41
Browse files Browse the repository at this point in the history
  • Loading branch information
Binh Vu committed Mar 3, 2024
1 parent 53e5e91 commit 0c540ca
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "web-sand"
version = "4.0.1"
version = "4.0.2"
description = "UI for browsing/editing semantic descriptions"
authors = ["Binh Vu <binh@toan2.com>"]
repository = "https://github.com/usc-isi-i2/sand"
Expand Down
10 changes: 10 additions & 0 deletions sand/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ def create(db, description: str, name: str):
Project(name=name, description=description).save()


@click.command(help="Remove a project")
@click.option("-d", "--db", required=True, help="sand database file")
@click.argument("name")
def remove(db, name: str):
"""Create project if not exist"""
init_db(db)
Project.get(name=name).delete_instance()


@click.group()
def cli():
pass
Expand All @@ -88,6 +97,7 @@ def cli():
cli.add_command(init)
cli.add_command(start)
cli.add_command(create)
cli.add_command(remove)
cli.add_command(load_dataset)


Expand Down
11 changes: 10 additions & 1 deletion 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.outputs.semantic_model import DataNode
from tqdm.auto import tqdm

from sand.models import (
Expand Down Expand Up @@ -53,12 +54,20 @@ def save_example(project: Project, example: Example[FullTable]):
row.save()

for i, sm in enumerate(example.sms):
# make sure that the semantic model has all columns in the table
newsm = sm.deep_copy()
for col in example.table.table.columns:
if not newsm.has_data_node(col.index):
newsm.add_node(
DataNode(col_index=col.index, label=col.clean_multiline_name or "")
)

SemanticModel(
table=mtbl,
name=f"sm-{i}",
description="",
version=1,
data=sm,
data=newsm,
).save()


Expand Down
2 changes: 1 addition & 1 deletion www/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sand",
"version": "2.2.3",
"version": "2.2.4",
"private": true,
"dependencies": {
"@ant-design/colors": "^6.0.0",
Expand Down
3 changes: 2 additions & 1 deletion www/src/pages/table/TablePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export const TablePage = withStyles(styles)(
}

return table.columns.map((col, columnIndex) => {
if (sm === undefined) return undefined;
if (sm === undefined || !sm.graph.hasColumnIndex(columnIndex))
return undefined;

const node = sm.graph.nodeByColumnIndex(columnIndex);
const datatypes: Set<DataType> = new Set(
Expand Down

0 comments on commit 0c540ca

Please sign in to comment.