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
Use, when possible, an ENV var to get the installation type #8500
Use, when possible, an ENV var to get the installation type #8500
Conversation
WINDOWS = "Windows" | ||
|
||
install_type_map = { | ||
APK: "APK", |
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 seems like a good way of constraining the values that end up in our analytics database - @jamalex any concerns with centralizing the possible values here?
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 helps with having this centrally documented/enforced, so the various installers don't go and do their own things, yeah.
Main thing is that it'd need to be considered a template/prefix, rather than a simple equivalence match.
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.
Slightly pedantic but possibly important: these are generally "runtime" types, not "installation" types.
APK = "apk" | ||
APT = "apt" | ||
KOLIBRI_SERVER = "kolibri-server" | ||
MACOS = "Mac" | ||
PEX = "pex" | ||
UWSGI = "uwsgi" | ||
WHL = "whl" | ||
WINDOWS = "Windows" | ||
|
||
install_type_map = { | ||
APK: "APK", | ||
APT: "APT - Debian package", | ||
KOLIBRI_SERVER: "kolibri(apt) with kolibri_server", | ||
MACOS: "MacOS Installer", | ||
PEX: "PEX file", | ||
UWSGI: "UWSGI process", | ||
WHL: "WHL Python package", | ||
WINDOWS: "Windows Installer", | ||
} |
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'm a bit confused why there are two inconsistent variations of these strings.
Also, if these are permanent strings that cannot be changed we might want to tighten them a bit and make them a bit more consistent and correct:
- package manager, file format, or operating system is the primary piece of info?
- "apt" is spelled two different ways above
- "MacOS" is actually spelled "macOS", and it's technically not an "installer", just an "app"
- For "Windows" we might want to distinguish the current "server" version from a potential future "app" version more similar to mac
APK = "apk" | |
APT = "apt" | |
KOLIBRI_SERVER = "kolibri-server" | |
MACOS = "Mac" | |
PEX = "pex" | |
UWSGI = "uwsgi" | |
WHL = "whl" | |
WINDOWS = "Windows" | |
install_type_map = { | |
APK: "APK", | |
APT: "APT - Debian package", | |
KOLIBRI_SERVER: "kolibri(apt) with kolibri_server", | |
MACOS: "MacOS Installer", | |
PEX: "PEX file", | |
UWSGI: "UWSGI process", | |
WHL: "WHL Python package", | |
WINDOWS: "Windows Installer", | |
} | |
ANDROID = "Android APK" | |
DEBIAN = "Debian package" | |
DEBIAN_APT = "Debian APT-installed package" | |
DEBIAN_APT_SERVER = "Debian APT package with kolibri-server" | |
MACOS_APP = "macOS desktop app" | |
PEX = "PEX executable" | |
UWSGI = "UWSGI process" | |
WHL = "WHL Python package" | |
WINDOWS_BG = "Windows background process" | |
runtime_types = ( | |
ANDROID, | |
DEBIAN, | |
DEBIAN_APT, | |
DEBIAN_APT_SERVER, | |
MACOS_APP, | |
PEX, | |
UWSGI, | |
WHL, | |
WINDOWS_BG, | |
) |
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.
The spec for this is here: #7960 this does need some updates to fit that spec (such as being able to insert the version number), but better to iterate there. Also, as there is already historic data in this format for some installers, updates may not be preferred for consistent analytics reporting.
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.
Ah, didn't realize there there was already data. At the least then there should only be one set of strings, not two? And we can still choose more consistent constant names even if the actual strings are a bit noisy.
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.
@rtibbles great, I was not aware of #7960 happy to fix these inconsistences after knowing the details.
@indirectlylit I agree with some of your changes (I didn't know we have an app for MacOs instead of an installer) but not with others, For Windows, for example installation type is clearly an installer, not a background process.
Also , there's not practical way to know if a Debian package has been installed using dpkg
or apt
, the current logic tries to find it out, but it can be easily cheated. In my opinion, we should just say "Deb package" removing the apt
reference.
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.
for what it's worth these comments are not critical or intended to be blocking.
For Windows, for example installation type is clearly an installer, not a background process.
Is it the "installation type" we care about or the runtime app? Sometimes it's both but often they are independent. This is like the Debian package which can be installed either with dpkg
or apt
.
The APK can be installed by sideloading or via the app store.
The current Windows repo contains three things:
- an installer script which runs once
- a background process (
kolibri.exe
) which runs Kolibri in the background, potentially on start-up - a small GUI which allows some basic config and control
Additionally at some point we'll also have a Windows "foreground app" similar to the Endless, Android, and macOS apps based on this repo. When this happens, it may also have its own installer.
In my opinion, we should just say "Deb package" removing the apt reference.
agreed!
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.
Is it the "installation type" we care about or the runtime app?
well, this is a part of a function called installation_type
😄 , probably knowing the runtime app is useful too, but when trying to get information from the user to solve issues, knowing how Kolibri was installed is important.
Main thing here is updating to match the spec: (and, as noted in the comment, ensuring that the set of constants are treated as prefixes, rather than exact matches) |
73d4185
to
2c8d77d
Compare
@jamalex done according to the specs (I have updated the description of this PR accordingly). |
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 looks good to me overall, functionally!
I note that it seems the install_type
variable is used to hold the keys from the constants, rather than the values, but we also store the value from the envvar in there. I had been imagining that the envvar passed in from the installer would be the full value (including the version, etc). Do you see any issues with that, either on the installer side (detecting version etc there, to put in the envvar) or here, with the codepaths (it seems like it would probably just skip over the other code and directly return the value from the envvar, so we'd be fine here)? It's nice having the fallback logic here just in case, too.
My main concern is having envvars with spaces or other chars to separate version and installer type, I am not sure that will work correctly in the different combinations of OS/installers we have. If you prefer the installer to provide the version I'd go for one envvar for the installer type and another for the version. |
if hasattr(output, "decode"): # needed in python 2.x | ||
output = output.decode("utf-8") | ||
package_info = output.split("\n") | ||
version_info = [output for output in package_info if "Version" in output] |
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.
Not sure why this line didn't raise an issue before, but it's now causing a python 2 syntax check flake8 failure:
kolibri/utils/server.py:929:40: F812 list comprehension redefines 'output' from line 927
https://github.com/indirectlylit/kolibri/runs/4301449205?check_suite_focus=true
Perhaps this should be:
version_info = [info for info in package_info if "Version" in info]
Weirdly, I see the linting error in my fork but not in the LE org repo.
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.
interesting, the check is skipped in LE but not in my repo:
https://github.com/learningequality/kolibri/runs/4301448839?check_suite_focus=true
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.
Oh - probably because the path match check looks back through the history of runs (which are constrained to a specific fork) so because the learning equality repo had a test run that had previously passed for this set of files, it doesn't run again, whereas your fork didn't.
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.
filed a follow-up here: #8772
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.
weird, that's not new code, it has been there since kolibri 0.11
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 think it is more likely a floating linter version issue than an issue with the CI setup.
Summary
Whenever it's available, use the
KOLIBRI_INSTALLATION_TYPE
env var to show the installation type instead of trying to guess itIn any case, with or without the env var, the output of the installation type follow the specs at https://docs.google.com/spreadsheets/d/1EpN4yIO9H0qkP0pY6jiEtfQIdyrEPChs3aDZwOMupcI/edit#gid=0
Example:
References
Closes: #7957
Reviewer guidance
Do the new constants names and descriptions make sense?
Testing checklist
PR process
Reviewer checklist
yarn
andpip
)