-
Notifications
You must be signed in to change notification settings - Fork 90
Add package version #409
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 package version #409
Conversation
setup.py
Outdated
@@ -8,7 +9,7 @@ | |||
"requests" | |||
], | |||
name="meilisearch", | |||
version="0.18.0", | |||
version=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.
I don't know if this works, is there a way to check this before accepting @alallema?
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.
Seems to work, or at least it doesn't cause an error.
python setup.py check
If you want to further verify you could publish this branch to Test PyPI https://test.pypi.org/.
I would suggest changing it to:
version=__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.
I don't know either, to be honest, I've never verified that it works that way. But like @sanders41 said, if it doesn't cause an error, it probably will.
setup.py
Outdated
@@ -8,7 +9,7 @@ | |||
"requests" | |||
], | |||
name="meilisearch", | |||
version="0.18.0", | |||
version=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.
Seems to work, or at least it doesn't cause an error.
python setup.py check
If you want to further verify you could publish this branch to Test PyPI https://test.pypi.org/.
I would suggest changing it to:
version=__version__
def test_get_version(): | ||
assert re.match(r'^(\d+\.)?(\d+\.)?(\*|\d+)$', VERSION) | ||
|
||
def test_get_qualified_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.
This function doesn't seem necessary so if it is removed this test can also be removed.
Hi @brunoocasali, |
I updated my suggestions based on the conversation about circular imports. The suggestions now should avoid that issue. |
3a5b41b
to
f4cb4eb
Compare
f4cb4eb
to
eebf948
Compare
@sanders41 @alallema can you look that now? Regarding the idea of moving the qualified_version method to the headers, @sanders41 do you mean, create this method there? Or just use the value in a literal way? |
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.
LGTM
I think the only place this would ever get used is in the header so I am thinking, instead of a specific function, in from meilisearch.version import __version__
class HttpRequests:
def __init__(self, config: Config) -> None:
self.config = config
self.headers = {
'Authorization': f'Bearer {self.config.api_key}',
'User-Agent': f'Meilisearch Python (v{__version__})',
}
... That said having a function like you have isn't "wrong" in any way so it doesn't hurt to have it, I just can't think on any other time it would be used. @alallema what do you think? |
Oh yes, I agree, the only place it will be used is inside of the headers. I created a function to do that because is easy to test it in isolation. |
OK, this makes sense. Just a question...do you want to test a specific string like this? It has the potential to end up with failing tests that aren't really failing. I believe this happened on several of the clients when error messages changed. In this header case I can imagine it could have happened when the name changed from MeiliSearch to Meilisearch. If you do want to keep the function to test it I think I would move it to |
@brunoocasali, I think it doesn't bother to have a function but I totally agree with @sanders41, I think making it private would also avoid the breaking changes, and hopefully, we shouldn't have to change our name soon 😄 |
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.
LGTM! 🍗
Oh yes, I want because this format is what Meilisearch expects on the server-side. So if the format change I really want to be warned by tests regarding this specifications/telemetry-policies CC: @sanders41 @alallema |
bors merge |
433: Feature/Analytics r=alallema a=brunoocasali Added a pre-defined User-Agent header using `meilisearch.version` After the implementation the MeiliSearch server is outputting the expected 💯 `[2022-03-30T04:41:46Z INFO actix_web::middleware::logger] 192.168.208.3 "GET /indexes HTTP/1.1" 200 2 "-" "Meilisearch Python (v0.18.1)" 0.000619` Add Python support as requested here meilisearch/integration-guides#150 Related to #409 Co-authored-by: Bruno Casali <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.