Skip to content

Commit 462edb7

Browse files
author
boonhapus
committed
Merge branch 'dev'
2 parents d3ab13b + 3d43b11 commit 462edb7

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

cs_tools/__project__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.5.6"
1+
__version__ = "1.5.7"
22
__docs__ = "https://thoughtspot.github.io/cs_tools/"
33
__repo__ = "https://github.com/thoughtspot/cs_tools"
44
__help__ = f"{__repo__}/discussions/"

cs_tools/api/middlewares/logical_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def all( # noqa: A003
106106
info = self.ts.metadata.fetch_header_and_extras(metadata_type="DATA_SOURCE", guids=[connection_guid]) # type: ignore
107107

108108
# BUGFIX: SCAL-199984 .. eta 10.0.0.cl
109-
if info[0]["type"] == "Default":
109+
if not info or info[0]["type"] == "Default":
110110
continue
111111

112112
table["data_source"] = info[0]["header"]

cs_tools/cli/commands/self.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from cs_tools.cli.types import Directory
1515
from cs_tools.cli.ux import CSToolsCommand, CSToolsGroup, rich_console
1616
from cs_tools.settings import _meta_config as meta
17+
from cs_tools.sync import base
1718
from cs_tools.updater import cs_tools_venv
1819
from cs_tools.updater._bootstrapper import get_latest_cs_tools_release
1920
import rich
@@ -140,10 +141,11 @@ def analytics():
140141
def download(
141142
directory: pathlib.Path = typer.Option(help="location to download the python binaries to", click_type=Directory()),
142143
platform: str = typer.Option(help="tag describing the OS and CPU architecture of the target environment"),
143-
python_version: str = typer.Option(
144+
python_version: AwesomeVersion = typer.Option(
144145
metavar="X.Y", help="major and minor version of your python install", parser=AwesomeVersion
145146
),
146147
beta: bool = typer.Option(False, "--beta", help="if included, download the latest pre-release binary"),
148+
syncer_dialect: str = typer.Option(None, help="the name of the dialect to fetch dependencies for"),
147149
):
148150
"""
149151
Generate an offline binary.
@@ -156,14 +158,35 @@ def download(
156158
[b yellow]python -m sysconfig[/]
157159
158160
"""
161+
# DEV NOTE: @boonhapus, 2024/05/21
162+
#
163+
# The idea behind the offline installer is to simulate `pip install` by downloading
164+
# all the necessary packages to build our environment.
165+
#
159166
requirements = directory.joinpath("requirements")
167+
168+
log.info("Fetching latest CS Tools release from GitHub")
160169
release_info = get_latest_cs_tools_release(allow_beta=beta)
161170
release_tag = release_info["tag_name"]
162171

163-
venv = cs_tools_venv
172+
if syncer_dialect is not None:
173+
syncer_dir = utils.get_package_directory("cs_tools") / "sync" / syncer_dialect
174+
175+
if not syncer_dir.exists():
176+
log.error(f"Syncer dialect {syncer_dialect} not found")
177+
raise typer.Exit(1)
178+
179+
log.info(f"Fetching {syncer_dialect} syncer dependencies..")
180+
manifest = base.SyncerManifest.model_validate_json(syncer_dir.joinpath("MANIFEST.json").read_text())
181+
manifest.__ensure_pip_requirements__()
164182

165183
# freeze our own environment, which has all the dependencies needed to build
166-
frozen = {req for req in venv.pip("freeze", "--quiet").stdout.decode().split("\n") if "cs_tools" not in req}
184+
log.info("Freezing existing virtual environment..")
185+
frozen = {
186+
r
187+
for r in cs_tools_venv.pip("freeze", "--quiet", visible_output=False).stdout.decode().split("\n")
188+
if "cs_tools" not in r
189+
}
167190

168191
# add in the latest release
169192
frozen.add(f"cs_tools @ https://github.com/thoughtspot/cs_tools/archive/{release_tag}.zip")
@@ -183,7 +206,8 @@ def download(
183206
if "win" in platform:
184207
frozen.add("pyreadline3 == 3.4.1") # from cs_tools
185208

186-
venv.pip(
209+
log.info("Downloading dependent packages..")
210+
cs_tools_venv.pip(
187211
"download", *frozen,
188212
"--no-deps", # we shouldn't need transitive dependencies, since we've build all the dependencies above
189213
"--dest", requirements.as_posix(),
@@ -199,6 +223,8 @@ def download(
199223
from cs_tools.updater import _bootstrapper, _updater
200224

201225
zip_fp = directory.joinpath(f"cs-tools_{__version__}_{platform}_{python_version}")
226+
227+
log.info(f"Preparing your download at {zip_fp}..")
202228
shutil.copy(_bootstrapper.__file__, requirements.joinpath("_bootstrapper.py"))
203229
shutil.copy(_updater.__file__, requirements.joinpath("_updater.py"))
204230
shutil.make_archive(zip_fp.as_posix(), "zip", requirements)

cs_tools/cli/tools/scriptability/_export.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from thoughtspot_tml.utils import determine_tml_type, disambiguate
1515

1616
from cs_tools.cli.ux import rich_console
17-
from cs_tools.errors import CSToolsError, CSToolsCLIError
17+
from cs_tools.errors import CSToolsCLIError
1818
from cs_tools.types import GUID, TMLSupportedContent, TMLSupportedContentSubtype
1919

2020
from .tmlfs import ExportTMLFS
@@ -44,7 +44,9 @@ def is_success(self) -> bool:
4444
return self.status_code == "OK"
4545

4646

47-
def export(ts, path, guids, tags, author, include_types, exclude_types, pattern, export_associated, org):
47+
def export(
48+
ts, path, guids, tags, author, include_types, exclude_types, exclude_system_content, pattern, export_associated, org
49+
):
4850
if guids and (tags or author or include_types or exclude_types or pattern):
4951
raise CSToolsCLIError(
5052
title="GUID cannot be used with other filters.",
@@ -110,6 +112,7 @@ def export(ts, path, guids, tags, author, include_types, exclude_types, pattern,
110112
pattern=pattern,
111113
include_types=include_types,
112114
include_subtypes=include_subtypes,
115+
exclude_system_content=exclude_system_content,
113116
exclude_types=exclude_types,
114117
exclude_subtypes=exclude_subtypes,
115118
)

cs_tools/cli/tools/scriptability/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def scriptability_export(
232232
"worksheet"
233233
),
234234
),
235+
include_system_content: bool = typer.Option(False, help="include System User content in export"),
235236
export_associated: bool = typer.Option(
236237
False, "--export-associated", help="if specified, also export related content (does not export connections)"
237238
),
@@ -261,6 +262,7 @@ def scriptability_export(
261262
pattern=pattern,
262263
include_types=include_types,
263264
exclude_types=exclude_types,
265+
exclude_system_content=not include_system_content,
264266
export_associated=export_associated,
265267
org=org_override,
266268
)

cs_tools/cli/tools/searchable/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class MetadataObject(ValidatedSQLModel, table=True):
140140
cluster_guid: str = Field(primary_key=True)
141141
org_id: int = Field(primary_key=True)
142142
object_guid: str = Field(primary_key=True)
143-
name: str
143+
name: str = Field(sa_column=Column(Text, info={"length_override": "MAX"}))
144144
description: Optional[str] = Field(sa_column=Column(Text, info={"length_override": "MAX"}))
145145
author_guid: str
146146
created: dt.datetime
@@ -218,7 +218,7 @@ class DependentObject(ValidatedSQLModel, table=True):
218218
cluster_guid: str = Field(primary_key=True)
219219
dependent_guid: str = Field(primary_key=True)
220220
column_guid: str = Field(primary_key=True)
221-
name: str
221+
name: str = Field(sa_column=Column(Text, info={"length_override": "MAX"}))
222222
description: Optional[str] = Field(sa_column=Column(Text, info={"length_override": "MAX"}))
223223
author_guid: str
224224
created: dt.datetime

0 commit comments

Comments
 (0)