Skip to content

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

Merged
merged 5 commits into from
Feb 16, 2022
Merged

Add package version #409

merged 5 commits into from
Feb 16, 2022

Conversation

brunoocasali
Copy link
Member

@brunoocasali brunoocasali commented Feb 14, 2022

  • Add a way to load the package version programmatically.
  • Change CONTRIBUTING.md and check-release scripts, since there is a new way to update the package version of the python SDK.

@brunoocasali brunoocasali added the enhancement New feature or request label Feb 14, 2022
setup.py Outdated
@@ -8,7 +9,7 @@
"requests"
],
name="meilisearch",
version="0.18.0",
version=VERSION,
Copy link
Member Author

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?

Copy link
Collaborator

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__

Copy link
Contributor

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,
Copy link
Collaborator

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():
Copy link
Collaborator

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.

@alallema
Copy link
Contributor

Hi @brunoocasali,
I don't have much to add thinks that @sanders41 had already made an excellent review 🎉 ❤️

@sanders41
Copy link
Collaborator

I updated my suggestions based on the conversation about circular imports. The suggestions now should avoid that issue.

@brunoocasali
Copy link
Member Author

brunoocasali commented Feb 15, 2022

@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?

Copy link
Collaborator

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

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

LGTM

@sanders41
Copy link
Collaborator

sanders41 commented Feb 15, 2022

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?

I think the only place this would ever get used is in the header so I am thinking, instead of a specific function, in _httprequests.py

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?

@brunoocasali
Copy link
Member Author

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.

@sanders41
Copy link
Collaborator

sanders41 commented Feb 15, 2022

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 _httprequests.py and make it private. That way if you decide you want to change the header in the future you can do it without it being a breaking change.

@alallema
Copy link
Contributor

alallema commented Feb 16, 2022

@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 😄

Copy link
Contributor

@alallema alallema left a comment

Choose a reason for hiding this comment

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

LGTM! 🍗

@brunoocasali
Copy link
Member Author

Just a question...do you want to test a specific string like this?

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

@alallema
Copy link
Contributor

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 16, 2022

@bors bors bot merged commit 5385c87 into main Feb 16, 2022
@bors bors bot deleted the add-version branch February 16, 2022 12:28
@brunoocasali brunoocasali mentioned this pull request Mar 30, 2022
bors bot added a commit that referenced this pull request Mar 30, 2022
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants