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

RHODS-8871: Remove mandatory typing from requests #186

Merged
merged 17 commits into from
Jun 9, 2023

Conversation

RobGeada
Copy link
Contributor

Metric requests now look like:

curl -X POST --location "http://{{host}}/metrics/spd/request" \
    -H "Content-Type: application/json" \
    -d "{
          \"modelId\": \"example-model-1\",
          \"protectedAttribute\": \"input-2\",
          \"favorableOutcome\": 1.0
          \"outcomeName\": \"output-0\",
          \"privilegedAttribute\": 1.0,
          \"unprivilegedAttribute\": 0.0
        }"

Request values are compared to see if they are compatible with the expected types from the metadata.

Many thanks for submitting your Pull Request ❤️!

Please make sure that your PR meets the following requirements:

  • You have read the contributors guide
  • Pull Request title is properly formatted: FAI-XYZ Subject
  • Pull Request title contains the target branch if not targeting main: [0.3.x] FAI-XYZ Subject
  • Pull Request contains link to the JIRA issue
  • Pull Request contains link to any dependent or related Pull Request
  • Pull Request contains description of the issue
  • Pull Request does not include fixes for issues other than the main ticket

@RobGeada RobGeada requested a review from a team as a code owner May 30, 2023 10:34
@RobGeada RobGeada requested review from ruivieira and tteofili and removed request for a team May 30, 2023 10:34
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented May 30, 2023

@RobGeada: This pull request references RHODS-8871 which is a valid jira issue.

In response to this:

Metric requests now look like:

curl -X POST --location "http://{{host}}/metrics/spd/request" \
   -H "Content-Type: application/json" \
   -d "{
         \"modelId\": \"example-model-1\",
         \"protectedAttribute\": \"input-2\",
         \"favorableOutcome\": 1.0
         \"outcomeName\": \"output-0\",
         \"privilegedAttribute\": 1.0,
         \"unprivilegedAttribute\": 0.0
       }"

Request values are compared to see if they are compatible with the expected types from the metadata.

Many thanks for submitting your Pull Request ❤️!

Please make sure that your PR meets the following requirements:

  • You have read the contributors guide
  • Pull Request title is properly formatted: FAI-XYZ Subject
  • Pull Request title contains the target branch if not targeting main: [0.3.x] FAI-XYZ Subject
  • Pull Request contains link to the JIRA issue
  • Pull Request contains link to any dependent or related Pull Request
  • Pull Request contains description of the issue
  • Pull Request does not include fixes for issues other than the main ticket

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci
Copy link

openshift-ci bot commented May 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RobGeada

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@danielezonca danielezonca left a comment

Choose a reason for hiding this comment

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

Overall looks good to me, some comments but mainly minor/codestyle

Good PR :)

sed -i "s#value: \"quay.io/trustyai/trustyai-service:latest\"#value: \"quay.io/trustyai/trustyai-service-ci:${BRANCH_SHA}#"
BRANCH_SHA=$(curl https://api.github.com/repos/trustyai-explainability/trustyai-explainability/pulls/164 | jq ".head.sha" | tr -d '"')
sed -i "s#value: \"quay.io/trustyai/trustyai-service:latest\"#value: \"quay.io/trustyai/trustyai-service-ci:${BRANCH_SHA}\"#" ./${KFDEF_FILENAME}
cat ./${KFDEF_FILENAME}
Copy link
Member

Choose a reason for hiding this comment

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

Leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is useful in the logs of the CI, I'd like to keep it

@@ -7,5 +7,6 @@ public enum DataType {
INT32,
INT64,
STRING,
MAP
MAP,
UNKNOWN,
Copy link
Member

Choose a reason for hiding this comment

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

Unused? I don't see any usage of it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which? I use UNKNOWN. Tommaso added MAP

return Response.ok(calculator.getDIRDefinition(request.getMetricValue(), request)).build();
final ReconciledMetricRequest reconciledMetricRequest;
try {
reconciledMetricRequest = ReconciledMetricRequest.reconcile(request, dataSource);
Copy link
Member

Choose a reason for hiding this comment

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

Why the reconcile method here is invoked in a try/catch while in the dir method this is not the case?
Are you sure the DataframeCreateException cannot happen in that method too?

Copy link
Contributor Author

@RobGeada RobGeada Jun 2, 2023

Choose a reason for hiding this comment

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

In this function, I'm calling:

ReconciledMetricRequest.reconcile(rawRequest, dataSource)

In dir, I'm calling:

ReconciledMetricRequest.reconcile(rawRequest, metadata)

The DataframeCreateException can be thrown on the creation of metadata from a dataSource, which happens only in the first invocation.

Comment on lines +58 to +64
this.privilegedAttribute = new TypedValue();
this.privilegedAttribute.setType(protectedType);
this.privilegedAttribute.setValue(request.getPrivilegedAttribute());

this.unprivilegedAttribute = new TypedValue();
this.unprivilegedAttribute.setType(protectedType);
this.unprivilegedAttribute.setValue(request.getUnprivilegedAttribute());
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure that privilegedAttribute and unprivilegedAttribute have the same type (protectedType)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They will need to, yes

Comment on lines +71 to +72
public static ReconciledMetricRequest reconcile(BaseMetricRequest request, Instance<DataSource> dataSource) {
final Metadata metadata = dataSource.get().getMetadata(request.getModelId());
Copy link
Member

Choose a reason for hiding this comment

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

It is a minor comment but I would prefer to do the get() outside this class (aka remove this overload and keep the other method) to avoid to bring usage of javax.enterprise.inject.Instance (aka J2EE) into this class.
As alternative you can replace Instance with Supplier and invoke this method like reconcile(request, dataSource::get)
Btw this is minor, it is mainly to limit the spreading of J2EE classes

Comment on lines +34 to +46
public ReconciledMetricRequest(String protectedAttribute, String outcomeName, String modelId, String requestName, String metricName, Double thresholdDelta, Integer batchSize,
TypedValue privilegedAttribute, TypedValue favorableOutcome, TypedValue unprivilegedAttribute) {
this.protectedAttribute = protectedAttribute;
this.outcomeName = outcomeName;
this.modelId = modelId;
this.requestName = requestName;
this.metricName = metricName;
this.thresholdDelta = thresholdDelta;
this.batchSize = batchSize;
this.privilegedAttribute = privilegedAttribute;
this.favorableOutcome = favorableOutcome;
this.unprivilegedAttribute = unprivilegedAttribute;
}
Copy link
Member

Choose a reason for hiding this comment

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

As far as I see it is not used, if so, can you remove it?
I'm not a fan of constructors with a lot of fields with the same type like here (String abc, String def, String ghi) because it is easy to swap a parameter and get a bug.
Especially if it is not used :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is used in the creation of the ReconciledDefinitionRequest class, in the super() invocation

@RobGeada
Copy link
Contributor Author

RobGeada commented Jun 2, 2023

/ok-to-test

@openshift-ci
Copy link

openshift-ci bot commented Jun 2, 2023

@RobGeada: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/trustyai-explainability-e2e 80928cc link true /test trustyai-explainability-e2e

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants