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

Api spec rework #213

Merged
merged 16 commits into from
Jun 3, 2024
Merged

Api spec rework #213

merged 16 commits into from
Jun 3, 2024

Conversation

brandon-groundlight
Copy link
Collaborator

We recently did a full re-haul of the public api spec. Functionality of the SDK should be unaffected, but this maps better onto what the service provides and sets up for improvements in the future.

@@ -21,7 +21,7 @@ generate: install-generator ## Generate the SDK from our public openapi spec
-g python \
-o ./generated \
--additional-properties=packageName=groundlight_openapi_client
poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py
poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py --strict-nullable
Copy link
Member

Choose a reason for hiding this comment

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

What does --strict-nullable do? For less obvious flags its helpful to comment them or link to their documentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, let me add a comment in the file itself, but the useful discussion is here. For properties in the api spec that have nullable: true the generated pydantic class should let that property be Optional. For strange reasons, you need to set --strict-nullable for this to be true.

description: ""
/v1/actions/detector/{detector_id}/rules:
$ref: '#/components/schemas/PaginatedRuleList'
description: ''
post:
operationId: Create rule
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
operationId: Create rule
operationId: Create detector rule

Copy link
Member

Choose a reason for hiding this comment

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

Just trying to add some parallelism to the name/description patterns

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 agreed with you at first, but then I realized this broke the parallelism to the delete rule endpoint. It's implicit that all rules belong to a detector

get:
operationId: get notes
description: Retrieve notes for a detector
operationId: List rules
Copy link
Member

Choose a reason for hiding this comment

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

Which rules? All the rules for a user? Or a group?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Users and groups should share the exact same set of rules, so I'm not sure if that should be differentiated

if metadata is not None:
detector_creation_input.metadata = str(url_encode_dict(metadata, name="metadata", size_limit_bytes=1024))
if confidence_threshold:
Copy link
Member

Choose a reason for hiding this comment

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

Was there a reason to reorder this? Not saying you need to change it just wondering if Im missing something

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I think I just happened to move it down while I was moving the pipeline_config default into the constructor

from groundlight_openapi_client.model.note_request import NoteRequest
from groundlight_openapi_client.model.rule_request import RuleRequest
from groundlight_openapi_client.model.verb_enum import VerbEnum
from model import Detector, PaginatedRuleList, Rule
Copy link
Member

Choose a reason for hiding this comment

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

Any idea why this is still considered Experimental? Should we change that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At some point this moves into the main client body, but I think we just haven't had the impetus to change this yet. This was our way of leaving a door open in case we wanted to change things later

Copy link
Member

@tyler-romero tyler-romero left a comment

Choose a reason for hiding this comment

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

LGTM, seems a lot nicer now! Can you give a bit more context in the description or a comment? Its not self explanatory what this improvement is setting up for.

@brandon-groundlight
Copy link
Collaborator Author

brandon-groundlight commented Jun 3, 2024

Its not self explanatory what this improvement is setting up for

This is mainly the corresponding SDK update to the new process of generating the api spec. The generated code had been rotting for a while, so this is mainly cleaning that before we attach more onto the sdk. The next likely change (and slightly overdue) change is to make confidence non-nullable, which inherently is a small update to the api-spec

@brandon-groundlight brandon-groundlight merged commit 02d3058 into main Jun 3, 2024
8 checks passed
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