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

python(feat): Report templates service #145

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

niliayu
Copy link
Collaborator

@niliayu niliayu commented Nov 26, 2024

This PR adds a ReportTemplateService that allows users to create, update, fetch, and archive report templates. There are also examples of how to define report templates in python, in yaml, and how to fetch, update, and archive those created templates. This also notably adds the ReportTemplateConfig as a pydantic model.

@niliayu niliayu marked this pull request as draft November 26, 2024 19:35
@niliayu niliayu marked this pull request as ready for review November 27, 2024 00:06
archived_date=archived_date,
)

field_mask = FieldMask(paths=["name", "description", "tags", "rules", "archived_date"])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was originally thinking we could be smarter about this and check each field to see which ones have actually changed, and just include those in the fieldmask, but I'm not sure if that buys us anything

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is "private" that should be fine? It's only accessible via the create_or_update_* method so I can't see any potential footguns but I'd just double check and consider this a bit more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I decided to leave this as-is for now.. I can't yet think of a way this might cause issues and this way allows us to keep the logic simpler for now. Let me know if you've had other thoughts in the meantime though

python/lib/sift_py/report_templates/service.py Outdated Show resolved Hide resolved
python/lib/sift_py/report_templates/service.py Outdated Show resolved Hide resolved
archived_date=archived_date,
)

field_mask = FieldMask(paths=["name", "description", "tags", "rules", "archived_date"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is "private" that should be fine? It's only accessible via the create_or_update_* method so I can't see any potential footguns but I'd just double check and consider this a bit more.

python/lib/sift_py/report_templates/config.py Outdated Show resolved Hide resolved
from sift_py.report_templates.config import ReportTemplateConfig


class ReportTemplateService:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we go pretty aggressive with the doc comments for this class? OPtional for the private method unless you think it'll help other devs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated! For the private ones I just added a docstring to the _update method to try to clarify how I'm doing things there.

python/lib/sift_py/ingestion/config/yaml/spec.py Outdated Show resolved Hide resolved
@@ -31,6 +32,25 @@ def read_and_validate(path: Path) -> TelemetryConfigYamlSpec:
return _validate_yaml(raw_config)


def load_report_templates(paths: List[Path]) -> List[ReportTemplateConfig]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should start breaking this yaml module apart. It is starting to feel awkward to have this be the dumping ground for parsing different yaml specs.

I think what make sense to me is having a top-level module along-side report_template maybe called yaml_specs and having the specs and parsing logic be separated by domain i.e. yaml_specs/report_template, yaml_specs/rule, yaml_spec/telemetry_config or something like that. We don't have to do this for everything right now, but can we move report templates logic out of this module? We can do the same for rule for your rules PR. We'll move telemetry config stuff out later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I think that sounds good! I'll go ahead and create this for report templates and then we can update this for the other domains the next time we touch them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated, let me know how that looks!

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.

2 participants