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

Update errors field in JSON Report #108

Merged
merged 8 commits into from
Feb 26, 2024
Merged

Update errors field in JSON Report #108

merged 8 commits into from
Feb 26, 2024

Conversation

mehrinkiani
Copy link
Member

@mehrinkiani mehrinkiani commented Feb 20, 2024

This PR updates errors and skipped field to have a category, description and source (optional for error) field for JSON reporting as outlined in #107.

Close #107

Sample result for a h5 model that does not have a model config:

    "summary": {
        "total_issues_by_severity": {
            "LOW": 0,
            "MEDIUM": 0,
            "HIGH": 0,
            "CRITICAL": 0
        },
        "total_issues": 0,
        "input_path": "tf_model.h5",
        "absolute_path": "/Users/mehrinkiani/Documents/modelscan",
        "modelscan_version": "0.0.0",
        "timestamp": "2024-02-22T15:59:25.994786",
        "scanned": {
            "total_scanned": 0,
            "scanned_files": []
        },
        "skipped": {
            "total_skipped": 1,
            "skipped_files": [
                {
                    "category": "MODEL_CONFIG",
                    "description": "Model Config not found",
                    "source": "tf_model.h5"
                }
            ]
        }
    },
    "issues": [],
    "errors": []
}
}

Sample results for a dependency error:

    "summary": {
        "total_issues_by_severity": {
            "LOW": 0,
            "MEDIUM": 0,
            "HIGH": 0,
            "CRITICAL": 0
        },
        "total_issues": 0,
        "input_path": "notebooks/KerasModels/unsafe_model.h5",
        "absolute_path": "/Users/mehrinkiani/Documents/modelscan/notebooks/KerasModels",
        "modelscan_version": "0.0.0",
        "timestamp": "2024-02-23T12:17:35.614094",
        "scanned": {
            "total_scanned": 0
        },
        "skipped": {
            "total_skipped": 0,
            "skipped_files": []
        }
    },
    "errors": [
        {
            "category": "DEPENDENCY",
            "description": "To use modelscan.scanners.H5LambdaDetectScan, please install modelscan with h5py extras. `pip install 'modelscan[ h5py ]'` if you are using pip."
        }
    ]
}

@mehrinkiani mehrinkiani marked this pull request as ready for review February 22, 2024 21:02
[], [ModelScanError("pytorch", f"Invalid magic number for file {source}")]
[],
[
ModelScanError(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking this should be a skipped reason instead of an error. In the benchmarking we're encountering .bin files that aren't pytorch and we should just be skipping them instead of erroring

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @swashko for sharing this! I have now updated it to add them to skipped files

Copy link
Member

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some small style things, in general lgtm!

modelscan/modelscan.py Show resolved Hide resolved
modelscan/tools/picklescanner.py Outdated Show resolved Hide resolved
modelscan/skip.py Outdated Show resolved Hide resolved
modelscan/scanners/keras/scan.py Outdated Show resolved Hide resolved
Copy link
Member

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mehrinkiani mehrinkiani merged commit 6c7e7f4 into main Feb 26, 2024
8 checks passed
@mehrinkiani mehrinkiani deleted the 107-error-field branch February 26, 2024 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make errors field a list of dicts including source file
3 participants