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

feat(ruff): enable lint for Airflow and Perflint #22384

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ exclude = [
# https://docs.astral.sh/ruff/rules/
[lint]
select = [
"AIR", # Airflow
"E", # pycodestyle
"F", # Pyflakes
"FAST", # FastAPI
"I", # isort
"PERF", # Perflint
"PGH", # pygrep-hooks
"PL", # Pylint
"TRY", # tryceratops
Expand Down
15 changes: 7 additions & 8 deletions machine-learning/dali/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,23 @@ def download_sample_images(data_path: Path) -> None:
data_path.mkdir(parents=True, exist_ok=True)

# Create a class subdirectory (e.g., "class0")
class_dir = data_path / "class0"
class_dir.mkdir(parents=True, exist_ok=True)
class_dir_path = data_path / Path("class0")
class_dir_path.mkdir(parents=True, exist_ok=True)

# Sample image URLs
image_urls: list[str] = [
"https://raw.githubusercontent.com/pytorch/hub/master/images/dog.jpg"
]

# Download images into the class subdirectory
for i, url in enumerate(image_urls):
try:
filename = f"image_{i}.jpg"
filepath = class_dir / filename
try:
for i, url in enumerate(image_urls):
filepath = class_dir_path / f"image_{i}.jpg"
if not filepath.exists():
logger.info(f"Downloading {url} to {filepath}")
urllib.request.urlretrieve(url, str(filepath))
except Exception:
logger.exception(f"Error downloading {url}")
except Exception:
logger.exception(f"Error downloading {url}")


@pipeline_def(batch_size=2, num_threads=2, device_id=None)
Expand Down
8 changes: 4 additions & 4 deletions machine-learning/hm-docling/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def main() -> None:

converter = DocumentConverter()

for pdf_path in pdf_paths:
try:
try:
for pdf_path in pdf_paths:
# Convert PDF to markdown
res = converter.convert(pdf_path)
markdown_content = res.document.export_to_markdown()
Expand All @@ -41,8 +41,8 @@ def main() -> None:
markdown_path = pdf_path.with_suffix(".md")
markdown_path.write_text(markdown_content, encoding="utf-8")
logger.info(f"Converted {pdf_path.name}")
except Exception as e:
logger.info(f"Error processing {pdf_path.name}: {e}")
except Exception as e:
logger.info(f"Error processing PDFs: {e}")


if __name__ == "__main__":
Expand Down