Skip to content

Commit 6323f83

Browse files
committed
Add IDE launch
1 parent 0debee8 commit 6323f83

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

src/projspec/proj/ai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from projspec import ProjectSpec
1+
from projspec.proj.base import ProjectSpec
22

33

44
class AIEnabled(ProjectSpec):

src/projspec/proj/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def resolve(
151151
:param types: names of types to allow while parsing. If empty or None, allow all
152152
:param xtypes: names of types to disallow while parsing.
153153
"""
154-
if types and set(types) - set(registry):
154+
types = set(camel_to_snake(_) for _ in types or ())
155+
if types and types - set(registry):
155156
raise ValueError(f"Unknown types: {set(types) - set(registry)}")
156157
# sorting to ensure consistency
157158
for name in sorted(registry):
@@ -405,6 +406,7 @@ def make(self, qname: str, **kwargs):
405406
spec, artifact, name = None, qname, None
406407
else:
407408
spec, artifact, *name = qname.split(".")
409+
spec = camel_to_snake(spec)
408410
specs = [self.specs[spec]] if spec else self.specs.values()
409411
art = None
410412
for spec in specs:

src/projspec/proj/ide.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Code project container config within IDEs"""
2-
2+
from projspec.artifact import BaseArtifact
33
from projspec.proj import ProjectSpec
44

55

@@ -12,15 +12,28 @@ def match(self) -> bool:
1212
return self.proj.fs.exists(f"{self.proj.url}/.project/spec.yaml")
1313

1414
def parse(self) -> None:
15-
...
15+
from projspec.artifact.process import Process
16+
17+
# "opens" the project in the sense that it is set as the current context.
18+
# Editing still happens in jupyter/vscode/etc
19+
self.artifacts["set_project"] = Process(
20+
self.proj, cmd=["nvwb", "open", self.proj.url]
21+
)
22+
23+
# create:
24+
# https://docs.nvidia.com/ai-workbench/user-guide/latest/reference/user-interface/cli.html#create-project
1625

1726

1827
class JetbrainsIDE(ProjectSpec):
1928
def match(self) -> bool:
2029
return self.proj.fs.exists(f"{self.proj.url}/.idea")
2130

2231
def parse(self) -> None:
23-
...
32+
from projspec.artifact.process import Process
33+
34+
self.artifacts["launch"] = Process(
35+
self.proj, cmd=["pycharm", self.proj.url, "nosplash", "dontReopenProjects"]
36+
)
2437

2538

2639
class VSCode(ProjectSpec):
@@ -32,7 +45,9 @@ def match(self) -> bool:
3245
return self.proj.fs.exists(f"{self.proj.url}/.vscode/settings.json")
3346

3447
def parse(self) -> None:
35-
...
48+
from projspec.artifact.process import Process
49+
50+
self.artifacts["launch"] = Process(self.proj, cmd=["code", self.proj.url])
3651

3752

3853
class Zed(ProjectSpec):
@@ -42,4 +57,6 @@ def match(self) -> bool:
4257
return self.proj.fs.exists(f"{self.proj.url}/.zed/settings.json")
4358

4459
def parse(self) -> None:
45-
...
60+
from projspec.artifact.process import Process
61+
62+
self.artifacts["launch"] = Process(self.proj, cmd=["zed", self.proj.url])

src/projspec/proj/published.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import yaml
22

3-
from projspec import ProjectSpec
3+
from projspec.proj.base import ProjectSpec
44

55

66
class Citation(ProjectSpec):

src/projspec/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import contextlib
22
import enum
33
import logging
4+
import os
45
import pathlib
56
import re
67
import subprocess

0 commit comments

Comments
 (0)