GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-149113: Add option to copy back data from Android testbed emulator to build machine by timrid · Pull Request #149271 · python/cpython Conversation
|
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Documentation build overview
73 files changed ·
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is very useful, I didn't know about this feature.
Apart from the more minor comments below, my main question is how this would integrate into cibuildwheel. Have you had any thoughts about that? There are some existing discussions about Docker containers that look relevant:
I think the most convenient solution from the package developer's point of view would be a cibuildwheel test-outputs option that maps directly to what you've implemented here: a list of paths to copy back from the temporary test directory. But since that directory has the same structure as the project directory (as it was created using test-sources), we can copy those paths back into the project directory, rather than a separate output directory.
This would make cibuildwheel much more transparent, allowing the developer to handle the output files in the same way as they would when running the tests directly. And it would allow more packages to have a single, portable test configuration which avoids platform-specific workarounds, {package} and {project} placeholders which don't work on mobile, and manual rearranging of files.
Since all cibuildwheel platforms run the tests from a temporary working directory, they would all support this option. On Linux it would copy the files from the temporary directory inside the Docker container to the project directory on the host. As the links above mention, there may be a use for another option (maybe build-outputs?) to copy out files from the build phase on Linux only. But that's not relevant to Android because only the test happens in a virtual machine, not the build.
@freakboy3742: This will probably come up on iOS at some point; what do you think? I guess it would be easier on iOS because the simulator doesn't have an isolated filesystem, but the command-line option in the testbed could be the same. Let's agree an approach and then discuss it with the cibuildwheel developers before we continue on this PR.
If we go this way, we can remove the --output-dir option from this PR. I would also rename --pull to --output, both for consistency with the cibuildwheel option name and to focus on the intent rather than the mechanism.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| // If the previous test run succeeded and nothing has changed, | ||
| // Gradle thinks there's no need to run it again. Override that. | ||
| afterEvaluate { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For clarity about when the code is run, this should be merged with the other afterEvaluate block below.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I moved the block into the other afterEvaluate block.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return tasks.register<Copy>("${deviceName}CopyTestOutput") { | ||
| from(layout.buildDirectory.dir(additionalOutputPath)) | ||
| // The subfolders of `connected_android_test_additional_output` contains | ||
| // names that are not equal to the serial of the device. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What are their names?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
E.g. outputs/connected_android_test_additional_output/debugAndroidTest/connected/SM-S911B - 13/
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // names that are not equal to the serial of the device. | ||
| // The subfolders of `managed_device_android_test_additional_output` are | ||
| // also unpredictable, because e.g. the subfolder for the "maxVersion" emulator | ||
| // is named "minVersion". |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
So what is the folder for minVersion called?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I now noticed, that minVersion has not worked at all. In my previous tests I probably saw an old output data from previous test runs. But even when I set minVersion to API level 29 it was also not working. Then I found out, that the output of the maxVersion device is always in the outputs folder:
outputs/managed_device_android_test_additional_output/debug/minVersion
and for minVersion (or other new devices I added) in the intermediates folder:
intermediates/managed_device_android_test_additional_output/debugAndroidTest/minVersionDebugAndroidTest
I am not quiet sure why, and on which factors this depends, but when searching in both directories it works much more stable if we would add new managed device configurations in the future.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| includeEmptyDirs = false | ||
| // Each android.py invocation runs only one device at a time, | ||
| // so there should never be more than one archive. Fail loudly | ||
| // if that assumption is violated. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This depends on __main__.py deleting the archive: if that fails for any reason, then subsequent runs may fail until the old archives are manually cleaned up. If the path really is unpredictable, then it would be safer for build.gradle.kts to delete any existing archives before running the tests.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You are right. I added a delete task before the tests are running.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| val pullPathsJson = args.getString("pythonPull") ?: return | ||
|
|
||
| // The output directory is created by AGP/UTP and points to a location inside | ||
| // the emulator's filesystem. AGP/UTP will pull everything from there back |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"UTP" doesn't seem to be a widely used term; suggest removing it everywhere to avoid confusion.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I removed "UTP" everywhere.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| val archiveName = "org.python.testbed-output.zip" | ||
|
|
||
| return tasks.register<Copy>("${deviceName}CopyTestOutput") { | ||
| from(layout.buildDirectory.dir(additionalOutputPath)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Based on the AGP source code, it looks like this feature might not be available below API level 29. So we should give an error if files were expected but weren't found.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You are right, for managed devices this is only working for API level >= 29. So the minVersion device is not running at all. I added a check if there is no file found.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I agree that cibuildwheel would be an obvious consumer for this sort of feature - but other than potentially consistency in language or option names, does the usage in cibuildwheel require any special consideration in the design here? The Android (and potentially iOS) runners have arguments; the cibuildwheel interface may choose to provide a way to leverage that option to expose the capability. In some sense, that option already exists in the form of the TEST_RUNTIME setting. To my mind, the feature analog here is really with Docker, not cibuildwheel - Docker is the "sandboxed test runner" from which files need to be exfiltrated; cibuildwheel calls docker, and a cibuildwheel user may need some of those files.
Agreed that it could be useful, and it would make sense to attempt to maintain parity between the iOS and Android testbed runners parity wherever we can.
Fully aware this is a bike shed - but I'm not convinced by this; To me, AFAICT, it makes sense to preserve two flags - where the content is coming from, and where it's going to; with the latter being There would then be an obvious mapping to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
For further discussion about the integration in cibuildwheel, I created pypa/cibuildwheel#2899.
I think we need the
I borrowed the name |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I agree the flag is needed; I'd lean to
I don't know that I have a better name than |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
> Task :app:compileDebugKotlin w: cpython/Platforms/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt:34:75 Parameter 'it' is never used, could be renamed to _
|
@mhsmith I've addressed all the points you mentioned, so this PR is ready for another review.
After thinking a bit more about the parameter name |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Sorry for the slow response. I'll be busy for the next few weeks preparing my projects for Python 3.15, and then I'll have some time to come back to this. Python 3.13 is about to go into security-only status, and even before that, the 2-month release cycle has been an inconvenience for cibuildwheel. So I'm also thinking of splitting out the testbed from CPython into a separate package so it's easier to update, and easier to use in other contexts (#158018). That should be done before adding any new features. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Copy files back from Android testbed emulator to host
There was an error while loading. Please reload this page.