Skip to content

Commit 3bc0c2d

Browse files
committed
update pre-push
1 parent 519e61f commit 3bc0c2d

5 files changed

Lines changed: 51 additions & 85 deletions

File tree

.githooks/pre-push

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ GITHOOKS_DIR="$REPO_ROOT/.githooks"
88
python_changed_files=($(git diff --name-only --diff-filter=ACM | grep '^python/lib/sift_client/' || true))
99

1010
if [[ -n "$python_changed_files" ]]; then
11-
echo "Python files changed, running Python stub checks..."
11+
echo "Python files changed, running Python formatting and linting..."
12+
bash "$GITHOOKS_DIR/pre-push-python/fmt-lint.sh"
13+
14+
echo "Running Python stub checks..."
1215
bash "$GITHOOKS_DIR/pre-push-python/stubs.sh"
1316
fi
1417

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Store the root directory of the repository
6+
REPO_ROOT="$(git rev-parse --show-toplevel)"
7+
PYTHON_DIR="$REPO_ROOT/python"
8+
9+
echo "Running Python formatting and linting with --fix..."
10+
11+
# Change to Python directory
12+
cd "$PYTHON_DIR"
13+
14+
# Run ruff format (formatter)
15+
echo "Running ruff format..."
16+
bash ./scripts/dev fmt
17+
18+
# Run ruff check with --fix (linter)
19+
echo "Running ruff check --fix..."
20+
bash ./scripts/dev lint-fix
21+
22+
# Check if any files were modified by formatting/linting
23+
cd "$REPO_ROOT"
24+
changed_files=$(git status --porcelain python/lib/sift_client/ | grep -E '\.py$' || true)
25+
26+
if [ -n "$changed_files" ]; then
27+
echo ""
28+
echo "ERROR: Formatting/linting made changes to the following files:"
29+
echo "$changed_files"
30+
echo ""
31+
echo "Please commit these changes before pushing."
32+
exit 1
33+
fi
34+
35+
echo "Python formatting and linting completed successfully."

.githooks/pre-push-python/stubs-check.sh

Lines changed: 0 additions & 62 deletions
This file was deleted.

python/lib/sift_client/_tests/resources/test_runs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,10 @@ async def test_update_run_name(self, runs_api_async, new_run):
325325
async def test_update_run_tags_and_metadata(self, runs_api_async, new_run):
326326
"""Test updating a run's tags and metadata."""
327327
try:
328-
# Update tags
328+
# Update tags and metadata
329329
update = RunUpdate(
330330
tags=["updated", "new-tag", "sift-client-pytest"],
331+
metadata={"test_key": "test_value", "number": 42.5, "flag": True},
331332
)
332333
updated_run = await runs_api_async.update(new_run, update)
333334

@@ -337,6 +338,9 @@ async def test_update_run_tags_and_metadata(self, runs_api_async, new_run):
337338
"new-tag",
338339
"sift-client-pytest",
339340
}
341+
assert updated_run.metadata["test_key"] == "test_value"
342+
assert updated_run.metadata["number"] == 42.5
343+
assert updated_run.metadata["flag"] is True
340344
finally:
341345
await runs_api_async.archive(new_run.id_)
342346

python/lib/sift_client/_tests/sift_types/test_calculated_channel.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def test_expression_helper(self):
4747

4848
# Verify expression is set in nested path
4949
assert (
50-
proto.calculated_channel_configuration.query_configuration.sel.expression
51-
== "$1 + $2"
50+
proto.calculated_channel_configuration.query_configuration.sel.expression == "$1 + $2"
5251
)
5352
assert "query_configuration" in mask.paths
5453

@@ -66,9 +65,7 @@ def test_expression_channel_references_helper(self):
6665
proto, mask = update.to_proto_with_mask()
6766

6867
# Verify channel references are converted
69-
refs = (
70-
proto.calculated_channel_configuration.query_configuration.sel.expression_channel_references
71-
)
68+
refs = proto.calculated_channel_configuration.query_configuration.sel.expression_channel_references
7269
assert len(refs) == 2
7370
assert refs[0].channel_reference == "$1"
7471
assert refs[0].channel_identifier == "channel1"
@@ -110,10 +107,7 @@ def test_all_assets_helper(self):
110107
proto, mask = update.to_proto_with_mask()
111108

112109
# Verify all_assets is set in nested path
113-
assert (
114-
proto.calculated_channel_configuration.asset_configuration.all_assets
115-
is True
116-
)
110+
assert proto.calculated_channel_configuration.asset_configuration.all_assets is True
117111
# Verify update_field is in mask (same as tag_ids and asset_ids)
118112
assert "asset_configuration" in mask.paths
119113

@@ -153,9 +147,7 @@ def test_expression_validator_rejects_references_without_expression(self):
153147
):
154148
CalculatedChannelUpdate(
155149
expression_channel_references=[
156-
ChannelReference(
157-
channel_reference="$1", channel_identifier="channel1"
158-
),
150+
ChannelReference(channel_reference="$1", channel_identifier="channel1"),
159151
],
160152
)
161153

@@ -210,9 +202,7 @@ def mock_calculated_channel(mock_client):
210202
class TestCalculatedChannel:
211203
"""Unit tests for CalculatedChannel model - tests properties and methods."""
212204

213-
def test_archive_calls_client_and_updates_self(
214-
self, mock_calculated_channel, mock_client
215-
):
205+
def test_archive_calls_client_and_updates_self(self, mock_calculated_channel, mock_client):
216206
"""Test that archive() calls client.calculated_channels.archive and calls _update."""
217207
archived_calc_channel = MagicMock()
218208
archived_calc_channel.is_archived = True
@@ -234,9 +224,7 @@ def test_archive_calls_client_and_updates_self(
234224
# Verify it returns self
235225
assert result is mock_calculated_channel
236226

237-
def test_unarchive_calls_client_and_updates_self(
238-
self, mock_calculated_channel, mock_client
239-
):
227+
def test_unarchive_calls_client_and_updates_self(self, mock_calculated_channel, mock_client):
240228
"""Test that unarchive() calls client.calculated_channels.unarchive and calls _update."""
241229
unarchived_calc_channel = MagicMock()
242230
unarchived_calc_channel.is_archived = False
@@ -258,9 +246,7 @@ def test_unarchive_calls_client_and_updates_self(
258246
# Verify it returns self
259247
assert result is mock_calculated_channel
260248

261-
def test_update_calls_client_and_updates_self(
262-
self, mock_calculated_channel, mock_client
263-
):
249+
def test_update_calls_client_and_updates_self(self, mock_calculated_channel, mock_client):
264250
"""Test that update() calls client.calculated_channels.update and calls _update."""
265251
updated_calc_channel = MagicMock()
266252
updated_calc_channel.description = "Updated description"

0 commit comments

Comments
 (0)