Skip to content

Conversation

@bmalezieux
Copy link
Contributor

Description

Related Issue

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

Checklist

  • I've read the CODE_OF_CONDUCT.md document.
  • I've read the CONTRIBUTING.md guide.
  • I've written tests for all new methods and classes that I created.
  • I've written the docstring in Google format for all the methods and classes that I used.
  • I've updated the pdm.lock running pdm update-lock (only applicable when pyproject.toml has been
    modified)
@bmalezieux bmalezieux requested a review from rabah-khalek May 14, 2024 15:04
@mattbit
Copy link
Member

mattbit commented May 21, 2024

@bmalezieux you might need something different, but for reference the AVID integration could be helpful (it also generates JSON reports from the scan, following the AVID schema).

@bmalezieux bmalezieux marked this pull request as ready for review June 3, 2024 15:35
Copy link
Contributor

@rabah-khalek rabah-khalek left a comment

Choose a reason for hiding this comment

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

since <detector>.run() produces a list of issues, which then you're looping over to jsonify, I would suggest to implicitly infer the detector names inside the run, and add this info to the issue's meta, which then you can group based on in to_json of ScanReport. detectors_names shouldn't be an input to the report, as we already have this info somewhere.

def to_json(self, filename=None):
results = {}
for suite_result in self.results:
results[suite_result.test_name] = "Passed" if suite_result.result.passed else "Failed"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add all the meta data that is available / could be useful?

  • metric value
  • model name
  • dataset(s) name(s)
with open(filename, "w") as json_file:
json.dump(results, json_file, indent=4)
else:
return results
Copy link
Contributor

Choose a reason for hiding this comment

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

I would perhaps return the json representation instead of the dict here

return json.dumps(results, indent=4)
Copy link
Contributor

Choose a reason for hiding this comment

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

Or let's simply remove this else, and always return the results


if isinstance(result, bool):
result = TestResult(passed=result)
print("TEMP: ", test_partial.test_id, result.passed)
Copy link
Contributor

Choose a reason for hiding this comment

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

to be removed

@bmalezieux bmalezieux requested a review from rabah-khalek June 5, 2024 14:44

class ScanReport:
def __init__(self, issues, model=None, dataset=None, as_html: bool = True):
def __init__(self, issues, model=None, dataset=None, detectors_names=None, as_html: bool = True):
Copy link
Contributor

Choose a reason for hiding this comment

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

i thought the idea was to remove this argument. Do we really need to know which detector didn't produce issues?

assert dest.read_text() == markdown


def test_scan_report_to_json():
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add a test where you pass the detector-names list to the scanreport, and check if the detector is in the json file

@rabah-khalek rabah-khalek self-requested a review June 10, 2024 12:40
@sonarqubecloud
Copy link

Please retry analysis of this Pull-Request directly on SonarCloud

@rabah-khalek rabah-khalek merged commit 5987d27 into main Jun 10, 2024
@rabah-khalek rabah-khalek deleted the json-report branch June 10, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants