Skip to content

Use mac version from python for linehaul information#2509

Merged
konstin merged 4 commits intomainfrom
konsti/delete-mac-version
Mar 20, 2024
Merged

Use mac version from python for linehaul information#2509
konstin merged 4 commits intomainfrom
konsti/delete-mac-version

Conversation

@konstin
Copy link
Copy Markdown
Member

@konstin konstin commented Mar 18, 2024

@konstin konstin added the internal A refactor or improvement that is not user-facing label Mar 18, 2024
@konstin konstin enabled auto-merge (squash) March 18, 2024 13:29
@samypr100
Copy link
Copy Markdown
Collaborator

samypr100 commented Mar 18, 2024

Note, it's not quite just major.minor, it should include the product version from the plist as-is based on my testing with pip. os_info got this right, hence why I used it for testing 😅

@konstin konstin disabled auto-merge March 18, 2024 13:58
@konstin
Copy link
Copy Markdown
Member Author

konstin commented Mar 18, 2024

Oh interesting, i'd need some mac user to test this then

@trag1c
Copy link
Copy Markdown
Contributor

trag1c commented Mar 18, 2024

🤔

λ ~ :: python -q
>>> import platform
>>> platform.mac_ver()[0]
'14.4'

@samypr100
Copy link
Copy Markdown
Collaborator

samypr100 commented Mar 18, 2024

@trag1c platform.mac version can include more. You're in 14.4 which got released, so its only major.minor (currently) Once 14.4.1 gets released you'll get 14.4.1.

@trag1c
Copy link
Copy Markdown
Contributor

trag1c commented Mar 18, 2024

Yeah I'm aware (I just recently updated from 14.2.1, what a shame 😢), but I thought you were referring to even more data than just major.minor[.patch] 👍

@samypr100
Copy link
Copy Markdown
Collaborator

@konstin If we want to use python and be compatible, we should just use the raw output of platform.mac_ver()[0]. That should take care of the test failing right now.

@trag1c
Copy link
Copy Markdown
Contributor

trag1c commented Mar 18, 2024

Yeah I'm aware (I just recently updated from 14.2.1, what a shame 😢), but I thought you were referring to even more data than just major.minor[.patch] 👍

I'm guessing beta releases could be different 🤔

@konstin
Copy link
Copy Markdown
Member Author

konstin commented Mar 18, 2024

If we want to use python and be compatible, we should just use the raw output of platform.mac_ver()[0]. That should take care of the test failing right now.

Sounds good, though it needs a mac user as reviewer

@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 18, 2024

What do you want me to test?

@konstin
Copy link
Copy Markdown
Member Author

konstin commented Mar 18, 2024

As @samypr100 said, we should pass platform.mac_ver()[0] verbatim next to the parsed major/minor and use it in the linehaul information, but i don't have reference devices for platform.mac_ver()[0]

@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 18, 2024

I get

❯ python3.12 -c "import platform; print(platform.mac_ver())"
('14.0', ('', '', ''), 'arm64')

@samypr100
Copy link
Copy Markdown
Collaborator

Here's what I get on an 14.3.1 mac

>  python -c 'import platform; print(platform.mac_ver())'
 ('14.3.1', ('', '', ''), 'arm64')

@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 18, 2024

Let's just send platform.mac_ver()[0] for now and address problems if they come up?

@samypr100
Copy link
Copy Markdown
Collaborator

Agreed, that's exactly what Pip does too https://github.com/pypa/pip/blob/24.0/src/pip/_internal/network/session.py#L159

@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 18, 2024

I guess this isn't trivial because we're not currently storing patch versions on Platform. We'd need to add patch: Option<u16> at

Macos { major: u16, minor: u16 },
and populate the value at in our retrieval script at

I'm not sure linehaul information justifies further changes here... patch macOS versions are not used afaik. We generate platform tags based on a major minor tuple (which is why we don't bother storing the optional patch version now).

I think we should consider documenting this caveat and moving on?

@samypr100
Copy link
Copy Markdown
Collaborator

samypr100 commented Mar 19, 2024

@zanieb the code currently behaves as expected per #2493 and it's fully compatible with linehaul. No more changes are technically needed.
I believe this PR was to see if we could remove mac_version.rs introduced in #2493 and leverage the python value of platform.mac_ver()[0] instead (assuming it was already there retrieved in a compatible way) per question in #2493 (comment).

Since it seems its not, I'd proposed we don't merge this change at this time to avoid sending invalid linehaul statistics which could be undesired.

@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 19, 2024

I'd prefer to use all the information we're already getting from Python (as we do here). I feel like we should see if the patch version is actually important to them. It seems weird that they'd have e.g. 14.4 imply 14.4.0 in their statistics.

@zanieb zanieb self-assigned this Mar 19, 2024
@samypr100
Copy link
Copy Markdown
Collaborator

samypr100 commented Mar 19, 2024

Fair, I don't think their parser cares and will use the value as-is, so I think it should be ok from a parser perspective.

My original concern was more that it could inflate statistics a bit biased towards versions without patch.

For example, say you have a 100 users using pip and uv where 50 of them have OSX version 14.3 and 50 have OSX version 14.3.1. The download stats would capture this subtle difference with pip where as with uv it would show 100 users on 14.3.

For what it's worth, they do test with osx patch versions https://github.com/pypi/linehaul-cloud-function/blob/main/tests/unit/ua/fixtures/pip.yml.

Worth asking @pradyunsg, as the original issue creator, does having the patch version matter in OSX in distro?

@pradyunsg
Copy link
Copy Markdown

I think it's OK to not have the patch version, but I'm also not a MacOS expert.

@konstin konstin force-pushed the konsti/delete-mac-version branch from ee3e87f to e6c2cc4 Compare March 19, 2024 14:42
@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 20, 2024

I hope you don't mind I pushed 637a9ce in an attempt to resolve the error you were encountering.

We really ought to use snapshots for these lineinfo tests though.

@konstin
Copy link
Copy Markdown
Member Author

konstin commented Mar 20, 2024

Thanks

I'm merging it now with the <major>.<minor> formatting for mac, it's easy enough to change later.

@konstin konstin merged commit 32b9eeb into main Mar 20, 2024
@konstin konstin deleted the konsti/delete-mac-version branch March 20, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants