GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Rate limit with project.directory.get_directory_list() · Issue #41 · diffgram/python-sdk

Rate limit with project.directory.get_directory_list() #41

New issue
Copy link
New issue
Copy link
Open
Open
Rate limit with project.directory.get_directory_list()#41
Copy link
Labels
infolowpriority

Description

@anthony-chaudhary
anthony-chaudhary
opened on Aug 23, 2022
Issue body actions

Solution

  1. Set init_default_directory = False when initting Project()
  2. use .get() and .new() methods
project = Project(
	project_string_id = "abc",
	client_id = "abc",
	client_secret = "abc",
	init_default_directory = False
)

try:
    directory = project.directory.get(name= "string_directory_name")
except: 
    directory = project.directory.new(name= "string_directory_name")

(this is instead of manually getting list and checking matches)

Context

existing_dirs = project.directory.get_directory_list()
will result in n number of calls for every dataset in the project

because eventually it calls init_files()
https://github.com/diffgram/python-sdk/blob/main/sdk/diffgram/core/directory.py#L76

in most cases this is not an issue but if a project has something like 300 datasets then every call is 300 x (number of calls in init_files)
so at least 300.

Future

  1. A "best practice" example of doing the above instead of iterating over list?
  2. Something like adding init false flag in the list concept too, e.g. so depending on use case if person doesn't need files

More generally we may need to reflect on "lazy loading" / expectations around one SDK call being "about" one API call

Activity

  1. anthony-chaudhary
    added
    info
    lowpriority
    on Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    infolowpriority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.