Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle unique org for apikeys #340

Merged
merged 8 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions nomic/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def _get_current_users_main_organization(self):
if organization["user_id"] == user["sub"] and organization["access_role"] == "OWNER":
return organization

for organization in user["organizations"]:
if organization["user_id"] == user["sub"]:
return organization
return {}

def _delete_project_by_id(self, project_id):
Expand Down Expand Up @@ -213,6 +216,9 @@ def _get_dataset_by_slug_identifier(self, identifier: str):
headers=self.header,
)

if response.status_code == 403:
raise ValueError(response.json()["detail"])

if response.status_code != 200:
return None

Expand Down Expand Up @@ -827,6 +833,9 @@ def _create_project(
organization_id = self._get_organization_by_slug(slug=identifier)
project_slug = identifier.split("/")[1]

if "/" in identifier:
org_name = identifier.split("/")[0]
logger.info(f"Organization name: `{org_name}`")
# supported_modalities = ['text', 'embedding']
# if modality not in supported_modalities:
# msg = 'Tried to create dataset with modality: {}, but Atlas only supports: {}'.format(
Expand Down