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

Configure metrics with yaml #66

Merged
merged 21 commits into from
Jul 12, 2022
Merged

Configure metrics with yaml #66

merged 21 commits into from
Jul 12, 2022

Conversation

Hebruwu
Copy link
Contributor

@Hebruwu Hebruwu commented Jul 5, 2022

No description provided.

@Hebruwu Hebruwu marked this pull request as ready for review July 7, 2022 15:11
@simonhkswan simonhkswan linked an issue Jul 8, 2022 that may be closed by this pull request
return {'name': self.name}

@classmethod
def metric_from_dict(cls, bluprnt: Dict[str, Any], check: Check = None):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def metric_from_dict(cls, bluprnt: Dict[str, Any], check: Check = None):
def from_dict(cls, bluprnt: Dict[str, Any], check: Check = None):

Comment on lines 50 to 66
@classmethod
def metrics_to_yaml_dump(cls, metrics: List):
"""
Dumps the given metrics into the print stream in a YAML format.
This is a prototype function and should be deleted/modified later.
"""
print(yaml.dump({"metrics": [m.to_dict() for m in metrics]}))

@classmethod
def metrics_from_yaml(cls, document: Union[IO, str], check: Check = None):
"""
Given a YAML document that contains a 'metrics' field, return a list of instances of the metrics within
the field.
"""
metric_bluprnts = yaml.safe_load(document)
return [_Metric.metric_from_dict(bluprnt=bluprnt, check=check) for bluprnt in metric_bluprnts['metrics']]

Copy link
Member

Choose a reason for hiding this comment

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

lets pull out these two methods

@sonarcloud
Copy link

sonarcloud bot commented Jul 11, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

94.3% 94.3% Coverage
0.0% 0.0% Duplication

Copy link
Member

@simonhkswan simonhkswan left a comment

Choose a reason for hiding this comment

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

Nicely done 👍🏼

@Hebruwu Hebruwu merged commit d7e435e into master Jul 12, 2022
@delete-merged-branch delete-merged-branch bot deleted the configure_metrics_with_yaml branch July 12, 2022 15:46
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.

Configure metrics with YAML
2 participants