Skip to content

Add support for hub.datalad.org #58

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

Merged
merged 7 commits into from
Feb 21, 2025
Merged

Add support for hub.datalad.org #58

merged 7 commits into from
Feb 21, 2025

Conversation

jwodder
Copy link
Member

@jwodder jwodder commented Feb 18, 2025

For #47.

This PR includes updates to datalad-repos.json and the READMEs for hub.datalad.org. Fetching all of the repositories took 13 minutes.

@jwodder jwodder marked this pull request as ready for review February 19, 2025 17:47
@jwodder jwodder requested a review from yarikoptic February 19, 2025 17:47
@jwodder jwodder mentioned this pull request Feb 19, 2025
@yarikoptic
Copy link
Member

Let's also restrict query only to non-private repos. On https://hub.datalad.org/api/swagger#/repository/repoSearch I see

image

so it could potentially include private repos for the user providing the token.

@jwodder
Copy link
Member Author

jwodder commented Feb 20, 2025

@yarikoptic Should this be done for GIN as well? If so, should anything be done to datalad-repos.json to remove private repositories?

@yarikoptic
Copy link
Member

yes, if it is a supported option there -- I didn't check

@yarikoptic
Copy link
Member

For now, since other work already builds on it, let's proceed with this and improve upon in subsequent PRs

Thank you @jwodder !!!

@yarikoptic yarikoptic merged commit 6c0f541 into master Feb 21, 2025
2 checks passed
@yarikoptic yarikoptic deleted the gh-47 branch February 21, 2025 13:37
@jwodder
Copy link
Member Author

jwodder commented Feb 21, 2025

@yarikoptic

  • This API reference does not list such a query parameter, and this comment states that /repos/search on GIN only returns public repositories.

  • Note that the repository objects do include a "private" field, so GIN does support private repositories.

  • Using the following script, I was able to find the private repository sanook/sanook on page 34 of the /repos/search results. For whatever reason, this repository is not listed in datalad-repos.json.

    #!/usr/bin/env -S pipx run
    # /// script
    # requires-python = ">=3.11"
    # dependencies = ["python-dotenv ~= 1.0", "requests ~= 2.20"]
    # ///
    
    from __future__ import annotations
    import os
    from dotenv import load_dotenv
    import requests
    
    
    def main() -> None:
        load_dotenv()
        with requests.Session() as s:
            s.headers["Authorization"] = "token " + os.environ["GIN_TOKEN"]
            url = "https://gin.g-node.org/api/v1/repos/search"
            page = 1
            while True:
                print(".", end="", flush=True)
                r = s.get(url, params={"page": page})
                if r.status_code == 500:
                    page += 1
                    continue
                r.raise_for_status()
                if repos := r.json()["data"]:
                    for repo in repos:
                        if repo["private"]:
                            print()
                            print(f"Found private repo {repo['full_name']} on page {page}")
                            return
                else:
                    break
                page += 1
    
    
    if __name__ == "__main__":
        main()
  • Adding private=false&is_private=false to an authenticated curl request for /repos/search?page=34 did not remove the private repository from the results.

@jwodder
Copy link
Member Author

jwodder commented Feb 21, 2025

@yarikoptic Please create an issue about handling of private repositories on hub.datalad.org and GIN.

@yarikoptic
Copy link
Member

done:

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

Successfully merging this pull request may close these issues.

2 participants