This document serves as a guide for converting the existing argparse-based CLI to use Click.
- Decorator-based Command Pattern
- Use
@click.command()and@click.group()decorators - Replace manual subparser creation with nested command groups
- Use
This document serves as a guide for converting the existing argparse-based CLI to use Click.
@click.command() and @click.group() decorators| { | |
| "permissions": { | |
| "allow": [ | |
| "Bash(git status:*)", | |
| "Bash(git diff:*)", | |
| "Bash(git log:*)", | |
| "Bash(git add:*)", | |
| "Bash(git grep:*)", | |
| "Bash(poetry update:*)", | |
| "Bash(pip show:*)", |
| { | |
| "permissions": { | |
| "allow": [ | |
| "Bash(git status:*)", | |
| "Bash(git diff:*)", | |
| "Bash(git log:*)", | |
| "Bash(poetry update:*)", | |
| "Bash(pip show:*)", | |
| "Bash(pip freeze:*)", | |
| "Bash(pip list:*)", |
| class Solution: | |
| openers = ["(", "{", "["] | |
| closers = [")", "}", "]"] | |
| valid = openers + closers | |
| def __init__(self): | |
| self.stack = [] | |
| def push(self, x): | |
| self.stack.append(x) |
| from collections import defaultdict | |
| from pprint import pprint | |
| class Solution: | |
| def longestCommonPrefix(self, strs: List[str]) -> str: | |
| str_count = len(strs) | |
| min_len = min([len(s) for s in strs]) | |
| print(f"Minimum string length: {min_len:,}") |
| from graphframes.lib import AggregateMessages as AM | |
| from graphframes.examples import Graphs | |
| from pyspark.sql.functions import sum as sqlsum | |
| g = Graphs(spark).friends() # Get example graph | |
| # For each user, sum the ages of the adjacent users | |
| msgToSrc = AM.dst["age"] | |
| msgToDst = AM.src["age"] |
| import os | |
| import glob | |
| import shutil | |
| import uuid | |
| from pyspark.sql.readwriter import DataFrameWriter | |
| def csv_single(self, path, **options): | |
| """ | |
| Write the DataFrame as a single CSV file at the specified path. |
| """Script that tests and times Relik's relation extraction and entity linking on the GraphFrames Paper: https://people.eecs.berkeley.edu/~matei/papers/2016/grades_graphframes.pdf""" | |
| import timeit | |
| import warnings | |
| from pprint import pprint | |
| from relik import Relik # type: ignore | |
| from relik.inference.data.objects import RelikOutput # type: ignore | |
| # Squash Relik's warnings for prettier screenshots | |
| warnings.simplefilter("ignore") |
| from pypdf import PdfReader | |
| # Load the PDF. The GraphFrames paper normally resides at | |
| # https://people.eecs.berkeley.edu/~matei/papers/2016/grades_graphframes.pdf | |
| reader = PdfReader("data/grades_graphframes.pdf") | |
| # Extract text from all pages | |
| text = "\n".join([page.extract_text() for page in reader.pages if page.extract_text()]) | |
| # Write it to a text file |
| You can see it linked many topics that are related - Apache Phoenix - but not actually mentioned in the text... |