Skip to content

Commit

Permalink
Finally fix validation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
robbibt authored Aug 2, 2024
1 parent 748297c commit e5936c9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 54 deletions.
45 changes: 20 additions & 25 deletions .github/workflows/dea-coastlines-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,26 @@ jobs:
--volume ${GITHUB_WORKSPACE}/tide_models:/var/share/tide_models \
dea_coastlines pytest -v --cov=coastlines --cov-report=xml tests
ls -l .
ls -l ./data/validation/processed/
ls -l ./tests/
git status
# # Commit validation results produced by integration tests back into repo
# - name: Commit validation results into repository
# uses: stefanzweifel/git-auto-commit-action@v4
# if: github.event_name == 'pull_request'
# continue-on-error: true
# with:
# commit_message: Automatically update integration test validation results
# file_pattern: 'tests/stats_tests.png tests/stats_tests.csv tests/README.md'
# Commit validation results produced by integration tests back into repo
- name: Commit validation results into repository
uses: stefanzweifel/git-auto-commit-action@v4
if: github.event_name == 'pull_request'
continue-on-error: true
with:
commit_message: Automatically update integration test validation results
file_pattern: 'tests/stats_tests.png tests/stats_tests.csv tests/README.md'

# # Post validation tesults as comment on PR
# - name: Post validation results as comment
# uses: mshick/add-pr-comment@v2
# if: github.event_name == 'pull_request'
# with:
# message: |
# ![](https://github.com/GeoscienceAustralia/dea-coastlines/blob/${{ github.head_ref }}/tests/stats_tests.png?raw=true")
# Post validation tesults as comment on PR
- name: Post validation results as comment
uses: mshick/add-pr-comment@v2
if: github.event_name == 'pull_request'
with:
message: |
![](https://github.com/GeoscienceAustralia/dea-coastlines/blob/${{ github.head_ref }}/tests/stats_tests.png?raw=true")
# For full integration test results, refer to the [Tests directory README](https://github.com/GeoscienceAustralia/dea-coastlines/tree/${{ github.head_ref }}/tests).
For full integration test results, refer to the [Tests directory README](https://github.com/GeoscienceAustralia/dea-coastlines/tree/${{ github.head_ref }}/tests).
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion coastlines/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2295,7 +2295,7 @@ def deacl_validation(
lambda x: pd.Series.mode(x).iloc[0]
)
count_vals = val_df.groupby(["year", "id"]).year.count().rename("n")
median_vals = val_df.groupby(["year", "id"]).median()
median_vals = val_df.groupby(["year", "id"]).median(numeric_only=True)

# Combine all aggregated stats into one dataframe
val_df = pd.concat(
Expand Down
56 changes: 28 additions & 28 deletions tests/test_coastline.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,34 @@ def test_generate_continental_cli():
# assert result.output == '' # for debugging
assert result.exit_code == 0

# @pytest.mark.dependency(depends=["test_generate_continental_cli"])
# def test_validation_cli(capsys):
# runner = CliRunner()
# result = runner.invoke(
# validation_cli,
# [
# "--inputs_path",
# "data/validation/interim/wrl_narrabeen",
# "--deacl_path",
# "data/processed/tests/coastlines_tests.gpkg",
# "--prefix",
# "tests",
# "--append_stats",
# "True",
# "--markdown_report",
# "True",
# ],
# )
@pytest.mark.dependency(depends=["test_generate_continental_cli"])
def test_validation_cli(capsys):
runner = CliRunner()
result = runner.invoke(
validation_cli,
[
"--inputs_path",
"data/validation/interim/wrl_narrabeen",
"--deacl_path",
"data/processed/tests/coastlines_tests.gpkg",
"--prefix",
"tests",
"--append_stats",
"True",
"--markdown_report",
"True",
],
)

# # Prepare detailed error information
# error_info = {
# "exit_code": result.exit_code,
# "output": result.output,
# "exception": str(result.exception) if result.exception else None,
# }
# Prepare detailed error information
error_info = {
"exit_code": result.exit_code,
"output": result.output,
"exception": str(result.exception) if result.exception else None,
}

# # Convert error_info to a formatted string
# error_details = json.dumps(error_info, indent=2)
# Convert error_info to a formatted string
error_details = json.dumps(error_info, indent=2)

# # Use the detailed error information in the assertion message
# assert result.exit_code == 0, f"Command failed. Error details:\n{error_details}"
# Use the detailed error information in the assertion message
assert result.exit_code == 0, f"Command failed. Error details:\n{error_details}"

0 comments on commit e5936c9

Please sign in to comment.