Skip to content

Commit aba2cbd

Browse files
manskxlexierule
authored andcommitted
Deprecate sheety API (#14004)
* deprecate sheety Co-authored-by: manskx <[email protected]> (cherry picked from commit b8739a0)
1 parent d59344b commit aba2cbd

File tree

4 files changed

+33
-25
lines changed

4 files changed

+33
-25
lines changed

src/lightning_app/cli/cmd_install.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import requests
1010

11+
from lightning_app.core.constants import LIGHTNING_APPS_PUBLIC_REGISTRY, LIGHTNING_COMPONENT_PUBLIC_REGISTRY
12+
1113
logger = logging.getLogger(__name__)
1214

1315

@@ -295,8 +297,16 @@ def _validate_name(name, resource_type, example):
295297

296298

297299
def _resolve_resource(registry_url, name, version_arg, resource_type):
300+
gallery_entries = []
298301
try:
299302
url = requests.get(registry_url)
303+
data = json.loads(url.text)
304+
305+
if resource_type == "app":
306+
gallery_entries = [a for a in data["apps"] if a["canDownloadSourceCode"]]
307+
308+
elif resource_type == "component":
309+
gallery_entries = data["components"]
300310
except requests.ConnectionError:
301311
m = f"""
302312
Network connection error, could not load list of available Lightning {resource_type}s.
@@ -306,12 +316,9 @@ def _resolve_resource(registry_url, name, version_arg, resource_type):
306316
sys.tracebacklimit = 0
307317
raise SystemError(m)
308318

309-
data = json.loads(url.text)
310-
data = data[resource_type + "s"]
311-
312319
entries = []
313320
all_versions = []
314-
for x in data:
321+
for x in gallery_entries:
315322
if name == x["name"]:
316323
entries.append(x)
317324
all_versions.append(x["version"])
@@ -473,12 +480,10 @@ def _install_component(git_url):
473480

474481

475482
def _resolve_app_registry():
476-
public_registry = "https://api.sheety.co/e559626ba514c7ba80caae1e38a8d4f4/lightningAppRegistry/apps"
477-
registry = os.environ.get("LIGHTNING_APP_REGISTRY", public_registry)
483+
registry = os.environ.get("LIGHTNING_APP_REGISTRY", LIGHTNING_APPS_PUBLIC_REGISTRY)
478484
return registry
479485

480486

481487
def _resolve_component_registry():
482-
public_registry = "https://api.sheety.co/e559626ba514c7ba80caae1e38a8d4f4/lightningAppRegistry/components"
483-
registry = os.environ.get("LIGHTNING_COMPONENT_REGISTRY", public_registry)
488+
registry = os.environ.get("LIGHTNING_COMPONENT_REGISTRY", LIGHTNING_COMPONENT_PUBLIC_REGISTRY)
484489
return registry

src/lightning_app/core/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
LIGHTNING_CREDENTIAL_PATH = os.getenv("LIGHTNING_CREDENTIAL_PATH", str(Path.home() / ".lightning" / "credentials.json"))
3333
DOT_IGNORE_FILENAME = ".lightningignore"
3434

35+
LIGHTNING_COMPONENT_PUBLIC_REGISTRY = "https://lightning.ai/v1/components"
36+
LIGHTNING_APPS_PUBLIC_REGISTRY = "https://lightning.ai/v1/apps"
37+
3538

3639
def get_lightning_cloud_url() -> str:
3740
# DO NOT CHANGE!

src/lightning_app/runners/cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def dispatch(
147147
# There can be only one app with unique project_id<>name pair
148148
lightning_app = list_apps_resp.lightningapps[0]
149149
else:
150-
app_body = Body7(name=app_config.name)
150+
app_body = Body7(name=app_config.name, can_download_source_code=True)
151151
lightning_app = self.backend.client.lightningapp_v2_service_create_lightningapp_v2(
152152
project.project_id, app_body
153153
)

tests/tests_app/cli/test_cmd_install.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def test_valid_org_app_name():
2727
assert result.exit_code
2828

2929
# assert a good (and availablea name) works
30-
real_app = "lightning/install-app"
30+
# This should be an app that's always in the gallery
31+
real_app = "lightning/invideo"
3132
result = runner.invoke(lightning_cli.install_app, [real_app])
3233
assert "Press enter to continue:" in result.output
3334

@@ -145,7 +146,7 @@ def test_component_install(real_component, test_component_pip_name):
145146

146147
def test_prompt_actions():
147148
# TODO: each of these installs must check that a package is installed in the environment correctly
148-
app_to_use = "lightning/install-app"
149+
app_to_use = "lightning/invideo"
149150

150151
runner = CliRunner()
151152

@@ -197,43 +198,42 @@ def test_version_arg_component(tmpdir, monkeypatch):
197198
def test_version_arg_app(tmpdir):
198199

199200
# Version does not exist
200-
app_name = "lightning/hackernews-app"
201+
app_name = "lightning/invideo"
201202
version_arg = "NOT-EXIST"
202203
runner = CliRunner()
203204
result = runner.invoke(lightning_cli.install_app, [app_name, f"--version={version_arg}"])
204205
assert f"app: 'Version {version_arg} for {app_name}' is not" in str(result.exception)
205206
assert result.exit_code == 1
206207

207208
# Version exists
208-
version_arg = "0.0.1"
209+
version_arg = "0.0.2"
209210
runner = CliRunner()
210211
result = runner.invoke(lightning_cli.install_app, [app_name, f"--version={version_arg}", "--yes"])
211212
assert result.exit_code == 0
212213

213214

214215
def test_proper_url_parsing():
215216

216-
name = "lightning/install-app"
217+
name = "lightning/invideo"
217218

218219
# make sure org/app-name name is correct
219220
org, app = cmd_install._validate_name(name, resource_type="app", example="lightning/lit-slack-component")
220221
assert org == "lightning"
221-
assert app == "install-app"
222+
assert app == "invideo"
222223

223224
# resolve registry (orgs can have a private registry through their environment variables)
224225
registry_url = cmd_install._resolve_app_registry()
225-
assert registry_url == "https://api.sheety.co/e559626ba514c7ba80caae1e38a8d4f4/lightningAppRegistry/apps"
226+
assert registry_url == "https://lightning.ai/v1/apps"
226227

227228
# load the component resource
228229
component_entry = cmd_install._resolve_resource(registry_url, name=name, version_arg="latest", resource_type="app")
229230

230231
source_url, git_url, folder_name, git_sha = cmd_install._show_install_app_prompt(
231232
component_entry, app, org, True, resource_type="app"
232233
)
233-
assert folder_name == "install-app"
234+
assert folder_name == "LAI-InVideo-search-App"
234235
# FixMe: this need to be updated after release with updated org rename
235-
assert source_url == "https://github.com/PyTorchLightning/install-app"
236-
assert git_url.find("@") > 10 # TODO: this will be removed once the apps repos will be public
236+
assert source_url == "https://github.com/Lightning-AI/LAI-InVideo-search-App"
237237
assert "#ref" not in git_url
238238
assert git_sha
239239

@@ -286,20 +286,20 @@ def test_install_app_shows_error(tmpdir):
286286
# os.chdir(cwd)
287287

288288

289-
def test_public_app_registry():
290-
registry = cmd_install._resolve_app_registry()
291-
assert registry == "https://api.sheety.co/e559626ba514c7ba80caae1e38a8d4f4/lightningAppRegistry/apps"
292-
293-
294289
@mock.patch.dict(os.environ, {"LIGHTNING_APP_REGISTRY": "https://TODO/other_non_PL_registry"})
295290
def test_private_app_registry():
296291
registry = cmd_install._resolve_app_registry()
297292
assert registry == "https://TODO/other_non_PL_registry"
298293

299294

295+
def test_public_app_registry():
296+
registry = cmd_install._resolve_app_registry()
297+
assert registry == "https://lightning.ai/v1/apps"
298+
299+
300300
def test_public_component_registry():
301301
registry = cmd_install._resolve_component_registry()
302-
assert registry == "https://api.sheety.co/e559626ba514c7ba80caae1e38a8d4f4/lightningAppRegistry/components"
302+
assert registry == "https://lightning.ai/v1/components"
303303

304304

305305
@mock.patch.dict(os.environ, {"LIGHTNING_COMPONENT_REGISTRY": "https://TODO/other_non_PL_registry"})

0 commit comments

Comments
 (0)