Skip to content
Snippets Groups Projects
Commit dcb28dcc authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Merge branch 'newchannel' into 'master'

Adapt our scripts to use our channel

See merge request !34
parents 43b234c5 f96e3992
No related branches found
No related tags found
1 merge request!34Adapt our scripts to use our channel
...@@ -4,13 +4,27 @@ set -xe ...@@ -4,13 +4,27 @@ set -xe
# usage create_new_env.sh (-n env_name|-p env_folder) pyver [bobver] # usage create_new_env.sh (-n env_name|-p env_folder) pyver [bobver]
# This is intented to be used only with our conda installation at idiap/group/torch5spro # This is intented to be used only with our conda installation at idiap/group/torch5spro
# example create_new_env.sh -n bob-2.3.4-py27_0 2.7 # example create_new_env.sh -n bob-2.3.4-py27_0 2.7
# example create_new_env.sh -n bob-2.3.4-py27_0 2.7 =2.3.4 # example create_new_env.sh -n bob-2.3.4-py27_0 2.7 =4.2.0
# example create_new_env.sh -n bob-2.3.4-py27_0 2.7 =2.3.4=py27_0 # example create_new_env.sh -n bob-2.3.4-py27_0 2.7 =4.2.0 =2.3.4
# example create_new_env.sh -n bob-2.3.4-py27_0 2.7 =4.2.0 =2.3.4=py27_0
# example create_new_env.sh -p /path/to/bob-2.2.0-py27_0 2.7 # example create_new_env.sh -p /path/to/bob-2.2.0-py27_0 2.7
conda create --yes $1 $2 --channel defaults --override-channels python=$3 anaconda conda create --yes $1 $2 \
--channel defaults \
--channel https://www.idiap.ch/software/bob/conda \
--override-channels \
python=$3 \
anaconda$4 \
bob$5 \
caffe \
tensorflow \
docopt \
sphinx_rtd_theme \
gcc \
coverage
source activate $2 source activate $2
conda install --yes --no-update-deps bob$4 caffe tensorflow ipdb docopt sphinx_rtd_theme gcc
pip install bob.db.arface \ pip install bob.db.arface \
bob.db.atvskeystroke \ bob.db.atvskeystroke \
bob.db.avspoof \ bob.db.avspoof \
...@@ -29,7 +43,6 @@ pip install bob.db.arface \ ...@@ -29,7 +43,6 @@ pip install bob.db.arface \
bob.db.replay \ bob.db.replay \
bob.db.scface \ bob.db.scface \
bob.db.utfvp \ bob.db.utfvp \
bob.db.voxforge \
bob.db.xm2vts \ bob.db.xm2vts \
bob.db.youtube \ bob.db.youtube \
bob.bio.base \ bob.bio.base \
...@@ -37,8 +50,9 @@ pip install bob.db.arface \ ...@@ -37,8 +50,9 @@ pip install bob.db.arface \
bob.bio.spear \ bob.bio.spear \
bob.bio.face \ bob.bio.face \
bob.bio.video \ bob.bio.video \
bob.db.voxforge \
gridtk \ gridtk \
coveralls ipdb
echo "You can now activate your environment like this:" echo "You can now activate your environment like this:"
echo "source activate $2" echo "source activate $2"
...@@ -62,6 +62,55 @@ def get_remote_md5_sum(url, max_file_size=100 * 1024 * 1024): ...@@ -62,6 +62,55 @@ def get_remote_md5_sum(url, max_file_size=100 * 1024 * 1024):
return hash.hexdigest() return hash.hexdigest()
class Gitlab(object):
"""A class that wraps Gitlab API using curl"""
def __init__(self, token):
super(Gitlab, self).__init__()
self.token = token
self.base_url = 'https://gitlab.idiap.ch/api/v3/'
def get_project(self, project_name, namespace='bob'):
cmd = ["curl", "--header",
"PRIVATE-TOKEN: {}".format(self.token),
self.base_url + "projects/{}%2F{}".format(
namespace, project_name)]
pipeline = subprocess.check_output(cmd)
return json.loads(pipeline.decode())
def create_pipeline(self, project_id):
cmd = ["curl", "--request", "POST", "--header",
"PRIVATE-TOKEN: {}".format(self.token),
self.base_url + "projects/{}/pipeline?ref=master".format(
project_id)]
pipeline = subprocess.check_output(cmd)
return json.loads(pipeline.decode())
def get_pipeline(self, project_id, pipeline_id):
cmd = ["curl", "--header",
"PRIVATE-TOKEN: {}".format(self.token),
self.base_url + "projects/{}/pipelines/{}".format(
project_id, pipeline_id)]
pipeline = subprocess.check_output(cmd)
return json.loads(pipeline.decode())
def create_merge_request(self, project_id, source_branch, target_branch, title,
assignee_id='', description='', target_project_id='',
labels='', milestone_id='', remove_source_branch=''):
url = "projects/{}/merge_requests?"
url += "&".join(['source_branch={}', 'target_branch={}', 'title={}'])
url += "&".join(['assignee_id={}', 'description={}', 'target_project_id={}',
'labels={}', 'milestone_id={}', 'remove_source_branch={}'])
url = url.format(project_id, source_branch, target_branch, title,
assignee_id, description, target_project_id, labels,
milestone_id, remove_source_branch)
cmd = ["curl", "--request", "POST", "--header",
"PRIVATE-TOKEN: {}".format(self.token),
self.base_url + url]
pipeline = subprocess.check_output(cmd)
return json.loads(pipeline.decode())
def main(package, direct_push=False): def main(package, direct_push=False):
stable_version = get_version(package) stable_version = get_version(package)
print('latest stable version for {} is {}'.format(package, stable_version)) print('latest stable version for {} is {}'.format(package, stable_version))
...@@ -73,29 +122,27 @@ def main(package, direct_push=False): ...@@ -73,29 +122,27 @@ def main(package, direct_push=False):
raise raise
temp_dir = tempfile.mkdtemp() temp_dir = tempfile.mkdtemp()
try: try:
print("\nClonning the feedstock") print("\nClonning bob.conda")
feedstock = os.path.join(temp_dir, '{}-feedstock'.format(package)) root = os.path.join(temp_dir, 'bob.conda')
feedstock = os.path.join(root, 'recipes', package)
try: try:
run_commands( run_commands(
['git', 'clone', ['git', 'clone',
'git@github.com:conda-forge/{}-feedstock.git'.format(package), 'git@gitlab.idiap.ch:bob/bob.conda.git',
feedstock]) root])
except ValueError: except ValueError:
print("\nThe feedstock does not exist on conda-forge. Exiting ...") print("\nFailed to clone `bob.conda`, Exiting ...")
raise raise
branch_name = '{}-{}'.format(package, stable_version)
os.chdir(feedstock) os.chdir(feedstock)
if not direct_push: if not direct_push:
run_commands( run_commands(
['git', 'remote', 'add', 'bioidiap', ['git', 'checkout', '-b', branch_name])
'git@github.com:bioidiap/{}-feedstock.git'.format(package)],
['git', 'checkout', '-b', stable_version])
# update meta.yaml # update meta.yaml
with open('recipe/meta.yaml') as f: meta_path = 'meta.yaml'
with open(meta_path) as f:
doc = f.read() doc = f.read()
if package == 'bob.math': build_number = '0'
build_number = '200'
else:
build_number = '0'
doc = re.sub(r'\{\s?%\s?set\s?version\s?=\s?".*"\s?%\s?\}', doc = re.sub(r'\{\s?%\s?set\s?version\s?=\s?".*"\s?%\s?\}',
'{% set version = "' + str(stable_version) + '" %}', '{% set version = "' + str(stable_version) + '" %}',
doc, count=1) doc, count=1)
...@@ -130,14 +177,10 @@ def main(package, direct_push=False): ...@@ -130,14 +177,10 @@ def main(package, direct_push=False):
'''.format(req=req) '''.format(req=req)
doc = doc[:be_id] + template + doc[te_id:] doc = doc[:be_id] + template + doc[te_id:]
with open('recipe/meta.yaml', 'w') as f: with open(meta_path, 'w') as f:
f.write(doc) f.write(doc)
conda_smithy_path = '' run_commands(['git', '--no-pager', 'diff'],
if os.path.isdir('/local/conda/bin/'):
conda_smithy_path = '/local/conda/bin/'
run_commands([conda_smithy_path+'conda-smithy', 'rerender'],
['git', '--no-pager', 'diff'],
['git', 'add', '-A']) ['git', 'add', '-A'])
try: try:
run_commands(['git', 'commit', '-am', run_commands(['git', 'commit', '-am',
...@@ -158,10 +201,12 @@ def main(package, direct_push=False): ...@@ -158,10 +201,12 @@ def main(package, direct_push=False):
'{}-feedstock/commits/master\n\n'.format(package)) '{}-feedstock/commits/master\n\n'.format(package))
else: else:
run_commands(['git', 'push', '--force', '--set-upstream', run_commands(['git', 'push', '--force', '--set-upstream',
'bioidiap', stable_version], 'origin', branch_name])
['hub', 'pull-request', '-b', 'conda-forge:master', gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN'))
'-h', 'bioidiap:{}'.format(stable_version), project_id = gitlab.get_project(package)['id']
'-m', 'Update to version {}'.format(stable_version)]) title = 'Update to version {}'.format(branch_name)
gitlab.create_merge_request(project_id, branch_name, 'master', title,
remove_source_branch='true')
finally: finally:
shutil.rmtree(temp_dir) shutil.rmtree(temp_dir)
......
...@@ -91,6 +91,22 @@ class Gitlab(object): ...@@ -91,6 +91,22 @@ class Gitlab(object):
pipeline = subprocess.check_output(cmd) pipeline = subprocess.check_output(cmd)
return json.loads(pipeline.decode()) return json.loads(pipeline.decode())
def create_merge_request(self, project_id, source_branch, target_branch, title,
assignee_id='', description='', target_project_id='',
labels='', milestone_id='', remove_source_branch=''):
url = "projects/{}/merge_requests?"
url += "&".join(['source_branch={}', 'target_branch={}', 'title={}'])
url += "&".join(['assignee_id={}', 'description={}', 'target_project_id={}',
'labels={}', 'milestone_id={}', 'remove_source_branch={}'])
url = url.format(project_id, source_branch, target_branch, title,
assignee_id, description, target_project_id, labels,
milestone_id, remove_source_branch)
cmd = ["curl", "--request", "POST", "--header",
"PRIVATE-TOKEN: {}".format(self.token),
self.base_url + url]
pipeline = subprocess.check_output(cmd)
return json.loads(pipeline.decode())
def main(packages_list): def main(packages_list):
gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN')) gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment