Skip to content

Commit

Permalink
Fix HTA OSS CI errors (facebookresearch#197)
Browse files Browse the repository at this point in the history
Summary:

Fix HTA OSS CI errors. 

This diff is a dup of D64839500. We can't directly work on D64839500 because commandeering a diff caused OSS sync stopped working.

Differential Revision: D64934436
  • Loading branch information
niufei8888 authored and facebook-github-bot committed Oct 25, 2024
1 parent 8e1db0c commit 61df30e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: ufmt
additional_dependencies:
- toml
- black == 22.8.0
- black == 24.3.0
- usort == 1.0.4

- repo: https://github.com/pycqa/flake8
Expand All @@ -29,8 +29,8 @@ repos:
args: [--show-source, --statistics]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.971'
rev: 'v1.2.0'
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports, --scripts-are-modules, --pretty]
additional_dependencies: [numpy==1.21.5]
args: [--no-strict-optional, --ignore-missing-imports, --explicit-package-bases, --scripts-are-modules, --pretty]
additional_dependencies: [numpy==1.23.5, types-requests]
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
#### Added
- Update pyproject.toml to workaround missing stub packages for yaml.
- Add trace format validator
- Added multiple trace filter classes and demos.
- Added enhanced trace call stack graph implementation.
Expand Down
11 changes: 5 additions & 6 deletions hta/configs/event_args_yaml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# pyre-strict


import importlib.resources
import re
from functools import lru_cache
from pathlib import Path
from typing import Callable, Dict, List, NamedTuple

import yaml
Expand Down Expand Up @@ -94,11 +94,10 @@ def from_string(version_str: str) -> "YamlVersion":

@lru_cache()
def parse_event_args_yaml(version: YamlVersion) -> EventArgs:
local_yaml_data_filepath = str(
importlib.resources.files(__package__).joinpath(
f"event_args_{version.get_version_str()}.yaml",
)
)
pkg_path: Path = Path(__file__).parent
yaml_file = f"event_args_{version.get_version_str()}.yaml"
local_yaml_data_filepath = str(pkg_path.joinpath("event_args_formats", yaml_file))

with open(local_yaml_data_filepath, "r") as f:
yaml_content = yaml.safe_load(f)

Expand Down
2 changes: 1 addition & 1 deletion hta/configs/parser_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TraceType(str, Enum):
Inference = "inference"


DEFAULT_PARSE_VERSION = v1_0_0
DEFAULT_PARSE_VERSION: YamlVersion = v1_0_0
DEFAULT_VER_EVENT_ARGS: EventArgs = parse_event_args_yaml(DEFAULT_PARSE_VERSION)
AVAILABLE_ARGS: Dict[str, AttributeSpec] = DEFAULT_VER_EVENT_ARGS.AVAILABLE_ARGS

Expand Down
1 change: 1 addition & 0 deletions hta/utils/validate_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def _check_args(
and isinstance(arg_value, float)
):
continue

type_violations[k] = (
f"key={k}: value={v} type={type(v)}; expect_type='{arg_type.name}' default_value={arg_value}"
)
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.black]
line-length = 88
line-length = 89
exclude = '''
/(
\.git
Expand All @@ -19,3 +19,7 @@ include_trailing_comma = true
use_parentheses = true
src_paths = ["hta", "tests"]
skip_glob = ["examples/*"]

[[tool.mypy.overrides]]
module = "yaml"
ignore_missing_imports = true

0 comments on commit 61df30e

Please sign in to comment.