Skip to content

Commit 6c3be64

Browse files
committed
feat: add explore() function
1 parent 066f10d commit 6c3be64

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

sdk/diffgram/core/directory.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ def all_file_ids(self):
109109
result = result + diffgram_ids
110110
return result
111111

112+
def explore(self):
113+
message = '{}/studio/annotate/{}/explorer?dataset_id={}'.format(
114+
self.client.host,
115+
self.project.project_string_id,
116+
self.id
117+
)
118+
print('\033[92m' + 'To Explore your dataset visit:' + '\033[0m')
119+
print('\033[96m' + message + '\033[0m')
120+
112121
def slice(self, query):
113122
from diffgram.core.sliced_directory import SlicedDirectory
114123
# Get the first page to validate syntax.

sdk/diffgram/core/sliced_directory.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from diffgram.core.directory import Directory
22
from diffgram.pytorch_diffgram.diffgram_pytorch_dataset import DiffgramPytorchDataset
33
from diffgram.tensorflow_diffgram.diffgram_tensorflow_dataset import DiffgramTensorflowDataset
4-
4+
import urllib
55

66
class SlicedDirectory(Directory):
77

@@ -26,6 +26,21 @@ def all_file_ids(self):
2626
result = result + diffgram_files
2727
return result
2828

29+
def explore(self):
30+
31+
32+
payload = {'dataset_id': self.original_directory.id, 'query': self.query}
33+
params = urllib.parse.urlencode(payload, quote_via = urllib.parse.quote)
34+
35+
message = '{}/studio/annotate/{}/explorer?{}'.format(
36+
self.client.host,
37+
self.project.project_string_id,
38+
params
39+
40+
)
41+
print('\033[92m' + 'To Explore your dataset visit:' + '\033[0m')
42+
print('\033[96m' + message + '\033[0m')
43+
2944
def to_pytorch(self, transform = None):
3045
"""
3146
Transforms the file list inside the dataset into a pytorch dataset.

0 commit comments

Comments
 (0)