Commit 231555df authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Re-organise code into more formal package structure

parent 40ceedb9
#!/usr/bin/env python #!/usr/bin/env python
# #
# __init__.py - # __init__.py - Miscellaneous functions used throughout fsl_ci.
# #
# Author: Paul McCarthy <pauldmccarthy@gmail.com> # Author: Paul McCarthy <pauldmccarthy@gmail.com>
# #
......
...@@ -18,7 +18,7 @@ import networkx as nx ...@@ -18,7 +18,7 @@ import networkx as nx
import jinja2 as j2 import jinja2 as j2
import yaml import yaml
from fsl_ci_utils.gitlab_api import (http_request, download_file) from fsl_ci.gitlab import (http_request, download_file)
def gen_recipe_path(project_path): def gen_recipe_path(project_path):
......
...@@ -13,9 +13,9 @@ import functools as ft ...@@ -13,9 +13,9 @@ import functools as ft
import urllib.parse as urlparse import urllib.parse as urlparse
import urllib.request as urlrequest import urllib.request as urlrequest
from fsl_ci_utils import (is_valid_project_version, from fsl_ci import (is_valid_project_version,
USERNAME, USERNAME,
EMAIL) EMAIL)
VERBOSE = True VERBOSE = True
...@@ -79,7 +79,7 @@ def parse_link_header(header, get='next'): ...@@ -79,7 +79,7 @@ def parse_link_header(header, get='next'):
url = url.strip('<>') url = url.strip('<>')
return url return url
except Exception as e: except Exception:
pass pass
return None return None
......
...@@ -15,20 +15,20 @@ import urllib.error as urlerror ...@@ -15,20 +15,20 @@ import urllib.error as urlerror
import yaml import yaml
from fsl_ci_utils.gitlab_api import (get_project_metadata, from fsl_ci.gitlab import (get_project_metadata,
set_project_metadata, set_project_metadata,
list_project_branches, list_project_branches,
download_file, download_file,
update_file, update_file,
find_suitable_runners, find_suitable_runners,
enable_runner, enable_runner,
get_runner_metadata, get_runner_metadata,
create_or_update_variable, create_or_update_variable,
create_branch, create_branch,
protect_branch, protect_branch,
open_merge_request, open_merge_request,
trigger_pipeline) trigger_pipeline)
from fsl_ci_utils.conda import is_standard_recipe_path from fsl_ci.conda import is_standard_recipe_path
SERVER_URL = 'https://git.fmrib.ox.ac.uk' SERVER_URL = 'https://git.fmrib.ox.ac.uk'
...@@ -152,10 +152,12 @@ def set_variables(project_path, ...@@ -152,10 +152,12 @@ def set_variables(project_path,
if project_path is not None: if project_path is not None:
create_or_update_variable( create_or_update_variable(
project_path, server, token, 'FSL_CI_API_TOKEN', ci_token, masked=True) project_path, server, token, 'FSL_CI_API_TOKEN',
ci_token, masked=True)
if recipe_path is not None: if recipe_path is not None:
create_or_update_variable( create_or_update_variable(
recipe_path, server, token, 'FSL_CI_API_TOKEN', ci_token, masked=True) recipe_path, server, token, 'FSL_CI_API_TOKEN',
ci_token, masked=True)
create_or_update_variable( create_or_update_variable(
recipe_path, server, token, 'FSLCONDA_RECIPE', 1) recipe_path, server, token, 'FSLCONDA_RECIPE', 1)
......
...@@ -17,19 +17,19 @@ from unittest import mock ...@@ -17,19 +17,19 @@ from unittest import mock
import jinja2 as j2 import jinja2 as j2
from fsl_ci_utils import (USERNAME, from fsl_ci import (USERNAME,
EMAIL, EMAIL,
indir, indir,
tempdir, tempdir,
sprun) sprun)
from fsl_ci_utils.gitlab_api import (project_exists, from fsl_ci.gitlab import (project_exists,
list_project_branches, list_project_branches,
create_repository, create_repository,
get_project_version, get_project_version,
open_merge_request) open_merge_request)
from fsl_ci_utils.conda import gen_recipe_path from fsl_ci.conda import gen_recipe_path
import fsl_project_dependencies as fsldeps import fsl_ci.utils.fsl_project_dependencies as fsldeps
SERVER_URL = 'https://git.fmrib.ox.ac.uk' SERVER_URL = 'https://git.fmrib.ox.ac.uk'
...@@ -368,7 +368,8 @@ def create_cpp_recipe_template(project_path, ...@@ -368,7 +368,8 @@ def create_cpp_recipe_template(project_path,
meta = { meta = {
'template_name' : recipe_name, 'template_name' : recipe_name,
'template_repository' : gen_repository_url(project_path, server), 'template_repository' : gen_repository_url(project_path,
server),
'template_recipe_repository' : gen_repository_url(recipe_path, server), 'template_recipe_repository' : gen_repository_url(recipe_path, server),
'exes' : exes 'exes' : exes
......
...@@ -14,7 +14,7 @@ import sys ...@@ -14,7 +14,7 @@ import sys
import shlex import shlex
import shutil import shutil
from fsl_ci_utils import (tempdir, indir) from fsl_ci import (tempdir, indir)
DEPENDENCY_REPLACEMENTS = { DEPENDENCY_REPLACEMENTS = {
......
...@@ -22,15 +22,14 @@ import argparse ...@@ -22,15 +22,14 @@ import argparse
import itertools as it import itertools as it
import urllib.parse as urlparse import urllib.parse as urlparse
from fsl_ci_utils.gitlab_api import (get_projects_in_namespace, from fsl_ci.gitlab import (get_projects_in_namespace,
download_file, download_file,
lookup_project_tags, lookup_project_tags,
get_divergence) get_divergence)
from fsl_ci_utils.conda import (Package, from fsl_ci.conda import (Package,
load_meta_yaml, load_meta_yaml,
get_channel_packages, get_channel_packages,
load_packages_from_recipe_repositories, load_packages_from_recipe_repositories)
build_dependency_graph)
SERVER_URL = 'https://git.fmrib.ox.ac.uk' SERVER_URL = 'https://git.fmrib.ox.ac.uk'
...@@ -111,7 +110,7 @@ def get_project_info(project_repo, server, token): ...@@ -111,7 +110,7 @@ def get_project_info(project_repo, server, token):
if len(tags) > 0: tag = tags[0] if len(tags) > 0: tag = tags[0]
else: tag = MISSING else: tag = MISSING
# the project repo is probably not on gitlab (e.g. on github) # the project repo is probably not on gitlab (e.g. on github)
except Exception as e: except Exception:
pass pass
return { return {
......
...@@ -13,8 +13,8 @@ import textwrap as tw ...@@ -13,8 +13,8 @@ import textwrap as tw
import sys import sys
import argparse import argparse
from fsl_ci_utils.gitlab_api import (create_or_update_variable, from fsl_ci.gitlab import (create_or_update_variable,
delete_variable) delete_variable)
SERVER_URL = 'https://git.fmrib.ox.ac.uk' SERVER_URL = 'https://git.fmrib.ox.ac.uk'
......
...@@ -14,11 +14,11 @@ import argparse ...@@ -14,11 +14,11 @@ import argparse
import multiprocessing.dummy as mp import multiprocessing.dummy as mp
import fsl_ci_utils.gitlab_api as gitlab import fsl_ci.gitlab as gitlab
from fsl_ci_utils.gitlab_api import (trigger_job, from fsl_ci.gitlab import (trigger_job,
find_latest_job, find_latest_job,
trigger_pipeline, trigger_pipeline,
wait_on_pipeline) wait_on_pipeline)
gitlab.VERBOSE = False gitlab.VERBOSE = False
...@@ -41,8 +41,9 @@ def trigger_build(project, server, token, production): ...@@ -41,8 +41,9 @@ def trigger_build(project, server, token, production):
variables = {'STAGING' : 'true'} variables = {'STAGING' : 'true'}
try: try:
pipeline = trigger_pipeline(project, 'master', server, token, variables) pipeline = trigger_pipeline(
except: project, 'master', server, token, variables)
except Exception:
return None return None
pid = pipeline['id'] pid = pipeline['id']
...@@ -52,7 +53,7 @@ def trigger_build(project, server, token, production): ...@@ -52,7 +53,7 @@ def trigger_build(project, server, token, production):
try: try:
status = wait_on_pipeline(project, pid, server, token) status = wait_on_pipeline(project, pid, server, token)
except: except Exception:
return None return None
print(f'Build pipeline for {project} has finished: {status}') print(f'Build pipeline for {project} has finished: {status}')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment