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

Add query runs method #107

Merged
merged 54 commits into from
Jun 13, 2019
Merged

Add query runs method #107

merged 54 commits into from
Jun 13, 2019

Conversation

eliasbenussi
Copy link
Contributor

No description provided.

faculty/clients/experiment.py Outdated Show resolved Hide resolved
faculty/clients/experiment.py Outdated Show resolved Hide resolved
@eliasbenussi eliasbenussi marked this pull request as ready for review May 14, 2019 11:07
@tommilata
Copy link
Member

It'd be nice to change delete_run and restore_runs to use the new schema too. I appreciate it's extra work, but I think it's worth it for the sake of consistency.

@tommilata
Copy link
Member

Did you consider using a library for the polymorphic filter type? E.g. https://github.com/marshmallow-code/marshmallow-oneofschema or https://github.com/Bachmann1234/marshmallow-polyfield. (I'm not saying we need to use it).

Copy link
Member

@tommilata tommilata left a comment

Choose a reason for hiding this comment

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

Well done, it guess it must be quite fiddly to write custom marshmallow schemas... I left a few comments. Also I'm not sure about marshmallow best practices around polymorphic types, so someone else's opinion might be useful.

tests/clients/test_experiment.py Outdated Show resolved Hide resolved
faculty/clients/experiment.py Outdated Show resolved Hide resolved
tests/clients/test_experiment.py Outdated Show resolved Hide resolved
tests/clients/test_experiment.py Outdated Show resolved Hide resolved
tests/clients/test_experiment.py Outdated Show resolved Hide resolved
@eliasbenussi
Copy link
Contributor Author

It'd be nice to change delete_run and restore_runs to use the new schema too. I appreciate it's extra work, but I think it's worth it for the sake of consistency.

@tomas-milata I agree that we should do it, but I was considering doing it in a separate PR. My reasoning is that the query_runs function we implemented was required in @acroz 's PR (#106) and so I would just like to get it out as soon as it's ready.

In fact I would say that, other than delete_runs and restore_runs, we could also reimplement list_runs to internally call query_runs as it is just a special case at this point -- although possibly a convenient one to have

@eliasbenussi
Copy link
Contributor Author

Did you consider using a library for the polymorphic filter type? E.g. https://github.com/marshmallow-code/marshmallow-oneofschema or https://github.com/Bachmann1234/marshmallow-polyfield. (I'm not saying we need to use it).

@tomas-milata I did not, but I after taking a look I think that:

  • the first one leads to a decoding that is unfortunately not correct for our payload (it explicitly specifies the type of the object). It adds a type field (although I think this can be removed), and it names the key for the value according to its type. Neither of these things are what we want.

  • the second one still requires to explicitly implement serialisation and deserialisation functions. This is verbose enough that I think our current implementation is basically just as good, with the advantage of one less dependency

@eliasbenussi
Copy link
Contributor Author

Did you consider using a library for the polymorphic filter type? E.g. https://github.com/marshmallow-code/marshmallow-oneofschema or https://github.com/Bachmann1234/marshmallow-polyfield. (I'm not saying we need to use it).

@tomas-milata I did not, but I after taking a look I think that:

  • the first one leads to a decoding that is unfortunately not correct for our payload (it explicitly specifies the type of the object). It adds a type field (although I think this can be removed), and it names the key for the value according to its type. Neither of these things are what we want.
  • the second one still requires to explicitly implement serialisation and deserialisation functions. This is verbose enough that I think our current implementation is basically just as good, with the advantage of one less dependency

Actually I think my points on the first one are wrong. That one might be a viable solution

Elias Benussi and others added 3 commits June 3, 2019 11:26
* Use marshmallow's `field.fail()` mechanism
* Map fitler types to field types with dict
* Factor out param filter type polymorphism

class CompoundFilterSchema(BaseSchema):
operator = EnumField(CompoundFilterOperator, by_value=True, required=True)
conditions = fields.List(FilterField(skip_if=None))
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 skip_if do? I can't find any mention of it in the documentation.

Copy link
Contributor

@haileyfong haileyfong Jun 7, 2019

Choose a reason for hiding this comment

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

I think this was added by mistake as all tests passed when I tried removing it. Thanks for spotting this out, I will remove it now.

@acroz acroz dismissed srstevenson’s stale review June 13, 2019 09:10

Changes made, want to merge.

@acroz acroz merged commit 23aecbf into master Jun 13, 2019
@acroz acroz deleted the add-query-runs-method branch June 13, 2019 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants