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

List projects under my account #235

Closed
YasmineMh opened this issue Nov 11, 2023 · 2 comments
Closed

List projects under my account #235

YasmineMh opened this issue Nov 11, 2023 · 2 comments

Comments

@YasmineMh
Copy link

Hey, is there a method to list all projects under my Nomic account?
Thanks!

@bmschmidt
Copy link
Collaborator

Unless I'm completely failing to find it, there is not--but there should be! We'll try to get something in the next release--I'll start off submitting the following function, which you can use in the meantime if it helps.

from nomic.project import AtlasClass
import requests

def list_projects(organization_id=None):
    """
    Lists all projects in an organization.

    If called without an organization id, it will list all projects in the
    current user's main organization.
    """
    c = AtlasClass()
    if organization_id is None:
        organization = c._get_current_users_main_organization()
        if organization is None:
            raise ValueError(
                "No organization id provided and no main organization found."
            )
        organization_id = organization['organization_id']
    response = requests.get(
        c.atlas_api_path + f"/v1/organization/{organization_id}",
        headers=c.header
    )
    proj_info = response.json()['projects']
    return [
        {'name': p['project_name'],
            'id': p['id'],
            'created_timestamp': p['created_timestamp']}
        for p in proj_info
    ]

@YasmineMh
Copy link
Author

Thank you @bmschmidt ! it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants