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

pulling blocks from catalog #381

Merged
merged 1 commit into from
May 14, 2024
Merged

pulling blocks from catalog #381

merged 1 commit into from
May 14, 2024

Conversation

WillRaphaelson
Copy link
Contributor

@WillRaphaelson WillRaphaelson commented May 7, 2024

Uncheckedin script used to cull the blocks metadata file, removing the archived collections

import json
import httpx

import httpx

def list_files_in_repo(owner, repo, path=""):
    """
    Lists files in a given GitHub repository at the specified path.

    Args:
    owner (str): GitHub username or organization
    repo (str): Repository name
    path (str): Directory path within the repository

    Returns:
    list of dict: List of files and directories in the specified path
    """
    api_url = f"https://api.github.com/repos/{owner}/{repo}/contents/{path}"
    response = httpx.get(api_url)

    # Check if the request was successful
    if response.status_code == 200:
        return response.json()
    else:
        print(f"Failed to retrieve data: {response.status_code}")
        return []

# Example usage
owner = "PrefectHQ"  # Replace with the actual owner's name
repo = "Prefect"  # Replace with the actual repository name
path = "docs/integrations/catalog"  # Specify path or leave empty for root directory
files = list_files_in_repo(owner, repo, path)




list_of_valid_collections = [file['name'][:-5] for file in files if file['type'] == 'file' and file['name'] != "TEMPLATE.yaml"]

list_of_valid_collections.append("prefect")

with open("views/aggregate-block-metadata.json", 'r') as file:
    data = json.load(file)

print(len(data))

new_dict = {key: value for key, value in data.items() if key in list_of_valid_collections}
new_dict = dict(sorted(new_dict.items()))

# print(len(new_dict))

print(len(new_dict["prefect"]["block_types"]))

prefect_dict = {key: value for key, value in new_dict["prefect"]["block_types"].items() if key not in ("string", "date-time", "json")}

new_dict["prefect"]["block_types"] = prefect_dict

json.dump(new_dict, open("views/aggregate-block-metadata.json", 'w'), indent=2)

@WillRaphaelson WillRaphaelson marked this pull request as ready for review May 14, 2024 16:35
@WillRaphaelson WillRaphaelson requested a review from a team as a code owner May 14, 2024 16:35
zzstoatzz
zzstoatzz previously approved these changes May 14, 2024
Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're removing primitives here?

@WillRaphaelson WillRaphaelson merged commit 6b579ea into main May 14, 2024
6 checks passed
@WillRaphaelson WillRaphaelson deleted the use-collections-catalog branch May 14, 2024 20:51
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