Skip to content

Commit

Permalink
removed formatting tools from make format to avoid formatting redunda…
Browse files Browse the repository at this point in the history
…ncy, we should have one source-of-truth for formatting, which is the pre-commit
  • Loading branch information
lu-ny committed Dec 11, 2024
1 parent d561a9c commit 7fc6481
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 27 deletions.
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ repos:
- id: ruff
args: ['--fix', '--config=pyproject.toml']
exclude: ^docs/|.*\.(json|yaml|md|txt)$
- id: ruff-format
args: ['--config=pyproject.toml']
exclude: ^docs/|.*\.(json|yaml|md|txt)$

# stage files after ruff
- repo: local
hooks:
- id: git-add
name: git-add
entry: git add
- id: run-make-format
name: Run Make Format
entry: make format
language: system
stages: [commit]
pass_filenames: true
pass_filenames: false

# - repo: https://github.com/pycqa/flake8
# rev: 4.0.1
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ setup:
format:
$(PYTHON) black $(SRC_DIR) --config pyproject.toml
$(PYTHON) ruff check --fix $(SRC_DIR)
$(PYTHON) ruff format $(SRC_DIR)
# remove git ls-files | xargs pre-commit run black --files, causes a circular dependency

# Run lint checks using Ruff
Expand Down
4 changes: 3 additions & 1 deletion adalflow/adalflow/components/retriever/bm25_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ def _initialize(self, corpus: List[List[str]]):

def _calc_idf(self):
idf_sum = 0
negative_idf = [] # idf can be negative if word is too common: more than half of the documents
negative_idf = (
[]
) # idf can be negative if word is too common: more than half of the documents
self.idf: Dict[str, float] = {}
for token, freq in self.nd.items():
idf = math.log(self.total_documents - freq + 0.5) - math.log(freq + 0.5)
Expand Down
4 changes: 3 additions & 1 deletion adalflow/adalflow/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def call(self, query: str) -> str:
training: bool
teacher_mode: bool = False
tracing: bool = False
name: str = "Component" # name will help with GradComponent output naming as "{name}_output"
name: str = (
"Component" # name will help with GradComponent output naming as "{name}_output"
)
_component_type = "base"

# def _generate_unique_name(self):
Expand Down
6 changes: 3 additions & 3 deletions adalflow/adalflow/optim/_llm_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def __init__(
# Ensure the temperature is at least 1
model_kwargs["temperature"] = max(1, model_kwargs.get("temperature", 1))

self.instruction_history: List[
Instruction
] = [] # trace the history of the instructions
self.instruction_history: List[Instruction] = (
[]
) # trace the history of the instructions
self.starter_instruction: Optional[str] = None
if self.instruction_parameter.data is not None:
self.starter_instruction = self.instruction_parameter.data
Expand Down
3 changes: 2 additions & 1 deletion adalflow/adalflow/optim/few_shot/bootstrap_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def sample(
)
# if demo.id in demos and demos[demo.id].score is not None:
w = (
w - student_demo_score
w
- student_demo_score
# w - demos[demo.id].score
) # assign higher weights to failed demos but successful in augmented
if w < 0:
Expand Down
6 changes: 3 additions & 3 deletions adalflow/adalflow/optim/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def __init__(
self._score: float = score # end to end evaluation score

self._student_traces: Dict[str, DataClass] = {} # id
self._demos: List[
DataClass
] = [] # used for the optimizer to save the proposed demos
self._demos: List[DataClass] = (
[]
) # used for the optimizer to save the proposed demos
self._previous_demos: List[DataClass] = []
self.eval_input = eval_input

Expand Down
3 changes: 2 additions & 1 deletion adalflow/adalflow/optim/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,8 @@ def _downsample_move_batch(
error_indices = [i for i, score in enumerate(acc_score_list) if score <= 0.5]

if (
len(error_indices) + len(correct_indices) <= max_moving_batch_size
len(error_indices) + len(correct_indices)
<= max_moving_batch_size
# and len(correct_indices) <= max_moving_batch_size
):
return all_samples, all_losses, all_y_preds, acc_score_list
Expand Down
6 changes: 3 additions & 3 deletions adalflow/adalflow/tracing/generator_state_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def __init__(
self.filename = filename or "generator_state_trace.json"
self.filepath = os.path.join(self.filepath, self.filename)

self._trace_map: Dict[
str, List[GeneratorStatesRecord]
] = {} # generator_name: [prompt_states]
self._trace_map: Dict[str, List[GeneratorStatesRecord]] = (
{}
) # generator_name: [prompt_states]
# load previous records if the file exists
if os.path.exists(self.filepath):
self.load(self.filepath)
Expand Down
6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,3 @@ lint.extend-ignore = [
"UP007", # Wants | over Union, which breaks 3.8
]
exclude = ["docs/*"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = 'auto'

0 comments on commit 7fc6481

Please sign in to comment.