-
Notifications
You must be signed in to change notification settings - Fork 12
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
Continuous integration strategy for Conda packages #228
Comments
CI Workflow for AppVeyor + CondaSetting Up Conda Authentication TokenBefore uploading to Anaconda Cloud, you must make an authentication token for your conda account # Login to your account:
> anaconda login
#Using Anaconda API: https://api.anaconda.org
#Username: lucaszw
#lucaszw's Password:
#login successful
# Generate an authentication token
> binstar auth -n someNameForToken --max-age 22896000 -c --scopes api Enter the token above using the AppVeyor UI located here: https://ci.appveyor.com/project/USERNAME/PROJECTNAME/settings/environment Select Environment Variables > Add Variable:
Sci-Bots-Configs RepositoryI setup a general purpose repository for holding all files relating to CI Worlkflow scripts, code snippets, and extra documents. When this repo is pushed to GitHub after making changes, the build script will update the build configuration for all packages in the wheeler-microfluidics organization listed in the wheeler-package-names.json file; and then cue them for re-build. Handling Packages / AppVeyor ProjectsTo make it easier to add , remove, and update batches of projects at once within AppVeyor I wrote up some documentation with code snippets here . Adding project to AppVeyor / Sci-Bots-Configs:
Adding all projects of organization to AppVeyor at once:AppVeyor's UI requires manually adding individual packages one at a time (this can be tedious, since the behavior of the add button also emits a javascript based re-direct response in the web browser ). Therefore for adding many projects at once, it is better to defer to the javascript console window, and use AppVeyors rest API. To make things more simple, AppVeyor exposes both the jQuery and Underscore JS frameworks (while also not requiring Authentication Tokens when making requests directly from the javascript console) 1. Retrieve all repositories in a github account / organization
2. Copy the value of the response, store as variable in javascript console window, and publish using AppVeyors rest API // Copy response from gitHub > Response
// Pase response into variable
var package_names = "{PASTE_HERE}"
_.each(package_names, function(name){
$.ajax({
type: "POST",
url: "https://ci.appveyor.com/projects",
data: {"repositoryProvider":"gitHub", "repositoryName":"{ORGANIZATION_NAME}/"+name},
error: function(d){console.log(d);}
});
}); 3. Add the package names to wheeler_package_names.json Generating CI FilesThe process of generating CI Files is automated using generate_ci_files.py . This file is called through Sci-Bots-Configs Appveyor.yml file. The process is outlined in the steps below:
YAML template for all packagesFor all packages, I used a standard template for the yaml file. This file is filled by generate_ci_files.py . The install and after test stage logic are separated into there own files linked here: install, after_test . environment:
GIT_REPOSITORY: {{git_url}}
matrix:
- PYTHON_VERSION: 2.7
MINICONDA: C:\Miniconda
PYTHON_ARCH: "32"
version: '{{version_number}}'
init:
- "ECHO %PYTHON_VERSION% %MINICONDA%"
install:
# Exit if no .conda-recipe folder
- IF NOT EXIST .conda-recipe exit 1
- git clone --depth=1 https://github.com/sci-bots/sci-bots-configs.git
- .\sci-bots-configs\appveyor-install.bat
# Handle build and tests using conda (defined in .conda-recipe/meta.yaml)
build: false
test_script:
- echo Build Complete
after_test:
- powershell -executionpolicy remotesigned -File .\sci-bots-configs\appveyor-after-test.ps1 Common config problemsFor the most part, packages should not need any modification in order to properly build on AppVeyor. However, particularily in cases where packages open separate processes'; modifications to the packages source code may be required in order to ensure AppVeyor can successfully terminate. An example of how to solve this for jupyter_helpers is shown below.
Sample CodeFor AppVeyor to build and terminate successfully, all threads started by tests must be terminated. Sample code for simplifying the termination of threads in python is shown below. class StoppableThread(Thread):
"""Thread class with a stop() method. The thread itself has to check
regularly for the stopped() condition.
From: https://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python"""
def __init__(self, *args, **kwargs):
super(StoppableThread, self).__init__(*args,**kwargs)
self._stop_event = threading.Event()
def stop(self):
self._stop_event.set()
def stopped(self):
return self._stop_event.is_set() def enqueue_output(out, queue):
""" Ensure break statement in StoppableThread target """
for line in iter(out.readline, b''):
if self.thread.stopped(): break
queue.put(line)
out.close() Resources
|
Will make a PR once all tasks are complete, but here is the fork I used for the above. |
Conda packaging
End goal
Each Conda package in any Sci-Bots related Conda package channels (e.g.,
wheeler-microfluidics
,microdrop-plugins
) should be set up with the following continuous integration workflow:Caveats: We already plan to deprecate some packages, so they will not need to be handled. Ryan and I will gladly go over a list of packages to indicate which packages can be skipped.
Sub tasks
jupyter-helpers
git
repowheeler-microfluidics
,microdrop-plugins
)* Can use
conda search --override-channels -c <channel name> --json
conda search
to:["about"]["url"]
field (should point to corresponding GitHub page)["about"]["url"]
field corresponds to Sci-Bots managedgit
repo (i.e., belonging to eitherwheeler-microfluidics
orsci-bots
GitHub organizations)git
repo and execute tool 4 to generate corresponding Appveyor configThe text was updated successfully, but these errors were encountered: