-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issues with scripts in module. add scope command. support ingest …
…parquet and jsonl.
- Loading branch information
Showing
22 changed files
with
210 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
import re | ||
import json | ||
import argparse | ||
from latentscope.util import get_data_dir | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Setup a scope') | ||
parser.add_argument('dataset_id', type=str, help='Dataset id (directory name in data folder)') | ||
parser.add_argument('embedding_id', type=str, help='Embedding id') | ||
parser.add_argument('umap_id', type=str, help='UMAP id') | ||
parser.add_argument('cluster_id', type=str, help='Cluster id') | ||
parser.add_argument('cluster_labels_id', type=str, help='Cluster labels id') | ||
parser.add_argument('label', type=str, help='Label for the scope') | ||
parser.add_argument('description', type=str, help='Description of the scope') | ||
|
||
def scope(dataset_id, embedding_id, umap_id, cluster_id, cluster_labels_id, label, description): | ||
DATA_DIR = get_data_dir() | ||
print("DATA DIR", DATA_DIR) | ||
directory = os.path.join(DATA_DIR, dataset_id, "scopes") | ||
|
||
def get_next_scopes_number(dataset): | ||
# figure out the latest scope number | ||
scopes_files = [f for f in os.listdir(directory) if re.match(r"scopes-\d+\.json", f)] | ||
if len(scopes_files) > 0: | ||
last_scopes = sorted(scopes_files)[-1] | ||
last_scopes_number = int(last_scopes.split("-")[1].split(".")[0]) | ||
next_scopes_number = last_scopes_number + 1 | ||
else: | ||
next_scopes_number = 1 | ||
return next_scopes_number | ||
|
||
next_scopes_number = get_next_scopes_number(dataset_id) | ||
# make the umap name from the number, zero padded to 3 digits | ||
id = f"scopes-{next_scopes_number:03d}" | ||
print("RUNNING:", id) | ||
|
||
scope = { | ||
"id": id, | ||
"embedding_id": embedding_id, | ||
"umap_id": umap_id, | ||
"cluster_id": cluster_id, | ||
"cluster_labels_id": cluster_labels_id, | ||
"label": label, | ||
"description": description | ||
} | ||
|
||
file_path = os.path.join(directory, id + ".json") | ||
with open(file_path, 'w') as f: | ||
json.dump(scope, f, indent=2) | ||
print("wrote scope", id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.