-
Notifications
You must be signed in to change notification settings - Fork 0
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
Mercelisvaughan model 1 #2
Conversation
… and added type hints to function
…PI that accepts a string for language and an integer for revision id, it will make the request and return the json response
…dded validation for response and unit test package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work getting started! You can add a more descriptive Pull request title. This will end up being a commit in our git history so it is good to have a title that makes sense when looking at commands like git log
# this method will make a request and return a json response | ||
#return response.json() | ||
return "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we create an abstract class we can just issue a pass
directive.
# this method will make a request and return a json response | |
#return response.json() | |
return "" | |
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completed the method
@@ -4,3 +4,43 @@ | |||
This is a Python package that acts as a client and allows users to make requests to the LiftWing API. | |||
Its purpose is to allow users to interact with the API by writing python code instead of manipulating HTTP requests. | |||
|
|||
Below is an example of how to make a request. This specific request is being made to the revert_risk API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the code from the README file as this file serves as our basic documentation. A user might only be interested on how to use
the package rather than deep dive from the start on what is does
behind the hood.
After we publish the package we can include an example of how to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the code
from liftwing_model import LiftwingModel | ||
|
||
class RevertRiskAPIModel(LiftwingModel): | ||
def __init__(self, base_url="https://api.wikimedia.org/service/lw/inference/v1/models/{language}-reverted:predict"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the url for the revertrisk model
"https://api.wikimedia.org/service/lw/inference/v1/models/{language}-reverted:predict"
This is the link to the relevant documentation for the revertrisk language agnostic model
https://api.wikimedia.org/wiki/Lift_Wing_API/Reference/Get_reverted_risk_language_agnostic_prediction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected the url
import json | ||
from liftwing_model import LiftwingModel | ||
|
||
class RevertRiskAPIModel(LiftwingModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good idea to keep only as base url the first part of the string
https://api.wikimedia.org/service/lw/inference/v1/models/
and the latter part will be the one specific to the model and can be hardcoded for now.
from liftwing_model import LiftwingModel | ||
|
||
class RevertRiskAPIModel(LiftwingModel): | ||
def __init__(self, base_url="https://api.wikimedia.org/service/lw/inference/v1/models/{language}-reverted:predict"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good idea to keep only as base url the first part of the string
https://api.wikimedia.org/service/lw/inference/v1/models/
and the latter part will be the one specific to the model and can be hardcoded for now like this:
self.model_name = "revertrisk-language-agnostic"
self.url = f"{base_url}{self.model_name}:predict"
@@ -0,0 +1,12 @@ | |||
import requests | |||
|
|||
class LiftwingModel: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be an abstract class and the request method can be an abstractmethod that has the following arguments:
- payload : dict
- method :str ="POST"
- headers : dict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets talk about the methods I added
.vscode/settings.json
Outdated
@@ -0,0 +1,5 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be deleted. Since we added it in the .gitignore fiel it also won't be committed automatically in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted
pyproject.toml
Outdated
@@ -0,0 +1,12 @@ | |||
[tool.poetry] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration for poetry is incomplete and throws an error when trying to run pip install -e .
File "/private/var/folders/0d/x7f69d5s525d0pn0gp8cyrzr0000gn/T/pip-build-env-46zwyrnz/overlay/lib/python3.11/site-packages/poetry/core/factory.py", line 60, in create_poetry
raise RuntimeError("The Poetry configuration is invalid:\n" + message)
RuntimeError: The Poetry configuration is invalid:
- The fields ['authors'] are required in package mode.
[end of output]
However I would suggest to use the more generic [project]
section instead of the poetry specific ones as described in the documentation (related PEP documentation)
It seems to be a future proof standard for python and poetry is going to adopt that as well as seen in its roadmap (related poetry PR).
Let me know if you need any help on this!
dependencies = [ | ||
"requests", | ||
] | ||
dynamic = ["version"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order for package installation to work (e.g. pip install -e .
this line should be removed:
We use a dynamic version when the version number isn't declared in this file but extracted from somewhere else.
In our case we define the version
field so if we set both we would get an error.
This is a pull request for the sample. This pull request is