Skip to content

Commit

Permalink
Change import qatools to import qaboard, while staying backward c…
Browse files Browse the repository at this point in the history
…ompatible
  • Loading branch information
arthur-flam committed Feb 17, 2020
1 parent 644c524 commit 70cab11
Show file tree
Hide file tree
Showing 34 changed files with 74 additions and 44 deletions.
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
recursive-include qatools/sample_project/qa *
include qatools/sample_project/qaboard.yaml
recursive-include qaboard/sample_project/qa *
include qaboard/sample_project/qaboard.yaml

9 changes: 9 additions & 0 deletions qaboard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# need to be update setup.py as well
__version__ = '0.8.2'
from .check_for_updates import check_for_updates
check_for_updates()

from .config import on_windows, on_linux, on_lsf, on_vdi, is_ci
from .config import config, merge
from .conventions import slugify
from .qa import qa
2 changes: 2 additions & 0 deletions qaboard/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .qa import main
main()
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions qatools/check_for_updates.py → qaboard/check_for_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def latest_qatools_version():
import re
try:
# we surely could do something more robust
r = requests.get('http://gitlab-srv/common-infrastructure/qatools/raw/master/setup.py', timeout=1)
r = requests.get('https://raw.githubusercontent.com/Samsung/qaboard/master/setup.py', timeout=1)
except:
return None
for l in r.text.split('\n'):
Expand Down Expand Up @@ -71,9 +71,9 @@ def check_for_updates():


if latest_version:
from qatools import __version__ as current_version
from qaboard import __version__ as current_version
to_ints = lambda v: [int(n) for n in v.split('.')]
newer_version_available = to_ints(current_version) < to_ints(latest_version)
if newer_version_available:
click.secho(f'A new version of qatools is available! Upgrade to {latest_version}:', fg='yellow', bold=True, err=True)
click.secho('$ pip install --upgrade --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org git+http://gitlab-srv/common-infrastructure/qatools', fg='yellow', err=True)
click.secho(f'[INFO] A new version of qaboard is available! Upgrade to {latest_version}:', fg='yellow', bold=True, err=True)
click.secho(' $ pip install --upgrade qaboard', fg='yellow', err=True)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion qatools/init.py → qaboard/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def qa_init():
pass
except:
import pkg_resources
qatools_dir = Path(pkg_resources.resource_filename('qatools', ''))
qatools_dir = Path(pkg_resources.resource_filename('qaboard', ''))

click.secho('Creating a `qatools` configuration based on the sample project 🎉', fg='green')
shutil.copy(str(qatools_dir / 'sample_project/qaboard.yaml'), 'qaboard.yaml')
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions qatools/qatools.py → qaboard/qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
@click.option('--database', type=PathType(), help="Input database location")
@click.option('--type', 'input_type', default=default_input_type, help="How we define inputs")
@click.option('--offline', is_flag=True, help="Do not notify QA-Board about run statuses.")
def cli(ctx, platform, configuration, label, tuning, tuning_filepath, dryrun, share, database, input_type, offline):
def qa(ctx, platform, configuration, label, tuning, tuning_filepath, dryrun, share, database, input_type, offline):
"""Entrypoint to running your algo, launching batchs..."""
# We want all paths to be relative to top-most qaboard.yaml
# it should be located at the root of the git repository
Expand Down Expand Up @@ -122,7 +122,7 @@ def cli(ctx, platform, configuration, label, tuning, tuning_filepath, dryrun, sh
ctx.obj['color'] = is_ci or share


@cli.command()
@qa.command()
@click.option('-i', '--input', 'input_path', type=PathType(), help='Path of the input/recording/test we should work on, relative to the database directory.')
@click.option('-o', '--output', 'output_path', type=PathType(), default=None, help='Custom output directory path. If not provided, defaults to ctx.obj["prefix_output_dir"] / input_path.with_suffix('')')
@click.argument('variable')
Expand All @@ -144,7 +144,7 @@ def get(ctx, input_path, output_path, variable):



@cli.command(context_settings=dict(
@qa.command(context_settings=dict(
ignore_unknown_options=True,
allow_interspersed_args=False,
))
Expand Down Expand Up @@ -293,7 +293,7 @@ def postprocess_(runtime_metrics, context, skip=False, save_manifests_in_databas



@cli.command(context_settings=dict(
@qa.command(context_settings=dict(
ignore_unknown_options=True,
))
@click.pass_context
Expand All @@ -318,7 +318,7 @@ def postprocess(ctx, input_path, output_path, forwarded_args):



@cli.command(context_settings=dict(
@qa.command(context_settings=dict(
ignore_unknown_options=True,
))
@click.pass_context
Expand All @@ -341,7 +341,7 @@ def sync(ctx, input_path, output_path):


lsf_config = config.get('runners').get('lsf', {}) if 'runners' in config else config.get('lsf', {})
@cli.command(context_settings=dict(
@qa.command(context_settings=dict(
ignore_unknown_options=True,
))
@click.option('--batch', '-b', 'batches', multiple=True, help="We run over all inputs+configs+database in those batches")
Expand Down Expand Up @@ -540,7 +540,7 @@ def batch(ctx, batches, batches_files, tuning_search, tuning_search_file, no_wai



@cli.command()
@qa.command()
@click.option('--file', '-f', 'files', multiple=True, help="Save spcific files instead of artifacts indicated by yaml file")
# Do we use this? let's deprecate and remove
@click.option('--out', '-o', 'artifacts_path', default='', help="Path to save artifacts in case of specified files")
Expand Down Expand Up @@ -629,7 +629,7 @@ def save_artifacts(ctx, files, artifacts_path, groups):
notify_qa_database(object_type='commit', **ctx.obj)


@cli.command()
@qa.command()
@click.pass_context
@click.option('--batch', '-b', 'batches', required=True, multiple=True, help="Only check bit-accuracy for this batch of inputs+configs+database.")
@click.option('--batches-file', 'batches_files', default=default_batches_files, multiple=True, help="YAML file listing batches of inputs+config+database selected from the database.")
Expand Down Expand Up @@ -681,7 +681,7 @@ def check_bit_accuracy_manifest(ctx, batches, batches_files):



@cli.command()
@qa.command()
@click.pass_context
@click.option(
"--reference",
Expand Down Expand Up @@ -751,7 +751,7 @@ def check_bit_accuracy(ctx, reference, batches, batches_files, reference_platfor
click.secho(f"https://qa/{config['project']['name']}/commit/{commit_id}?reference={reference_commit.hexsha}&selected_views=bit_accuracy", fg='red')
exit(1)

@cli.command(context_settings=dict(
@qa.command(context_settings=dict(
ignore_unknown_options=True,
))
@click.option('--batch', '-b', 'batches', required=True, multiple=True, help="Use the inputs+configs+database in those batches")
Expand Down Expand Up @@ -853,7 +853,7 @@ def optimize(ctx, batches, batches_files, config_file, forwarded_args):


def main():
cli(obj={}, auto_envvar_prefix='QA')
qa(obj={}, auto_envvar_prefix='QA')

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion qatools/qa_aggregate.py → qaboard/qa_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pathlib import Path

import click
from qatools.config import root_qatools, available_metrics
from qaboard.config import root_qatools, available_metrics



Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 19 additions & 8 deletions qatools/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# need to be update setup.py as well
__version__ = '0.8.2'
from .check_for_updates import check_for_updates
check_for_updates()
"""
For backward-compatibility: once qaboard was imported as "import qatools"
Inspired by https://stackoverflow.com/a/24324577/5993501
"""
import sys
import qaboard

from .config import on_windows, on_linux, on_lsf, on_vdi, is_ci
from .config import config, merge
from .conventions import slugify
from .qatools import cli
modules = [
'qaboard',
'qaboard.check_for_updates',
'qaboard.config',
'qaboard.utils',
'qaboard.conventions',
'qaboard.iterators',
'qaboard.qa',
'qaboard.lsf',
'qaboard.api'
]
for m in modules:
sys.modules[m.replace('qaboard', 'qatools')] = sys.modules[m]
2 changes: 0 additions & 2 deletions qatools/__main__.py

This file was deleted.

23 changes: 17 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,27 @@
# (works, ugly) patch: `+ verify=False` in lib/python37/site-packages/twine/repository.py:175
# (helps) ssh $nice_host
twine upload --verbose -u __token__ dist/*
Until https://github.com/pypa/pip/issues/2195 is resolved,
for local development with `pip install` without `--editable`,
you'll likely want to speed-up pip
```
# site-packages/pip/_internal/download.py
778: + from shutil import ignore_patterns
+ shutil.copytree(link_path, location, symlinks=True, ignore=ignore_patterns('.git', 'node_modules'))
- shutil.copytree(link_path, location, symlinks=True)
```
"""
# https://github.com/ninjaaron/fast-entry_points
import fastentrypoints

from pathlib import Path
from setuptools import setup, find_packages

# The directory containing this file
HERE = Path(__file__).parent
README = (HERE / "README.md").read_text(encoding='utf-8')
README_md = Path(__file__).parent / "README.md"
README = README_md.read_text(encoding='utf-8')

setup(
name='qaboard',
Expand All @@ -52,8 +63,8 @@
"Topic :: Software Development :: Quality Assurance",
],

python_requires='>=3.6',
packages=find_packages(exclude=("tests","backend")),
python_requires='>=3.6',
install_requires=[
'dataclasses', # Backport for python3.6
'click>=7.0', # CLI for humans. In v7 they changed CLI command conventions, started using "-" vs "_"
Expand All @@ -75,15 +86,15 @@
extras_require={
# Optionnal needed only for `qa optimize`
# Since its CLI usage is not straightforward, it's best kept at an optionnal dependency
# Enable with `pip install qatools[optimize]`
# Enable with `pip install qaboard[optimize]`
# Since the package is not maintained anymore, maybe we should review the optimization loop
# and use nevergrad like all the cool kids.
'optimize': ["skopt"],
},

entry_points={
"console_scripts": [
'qa = qatools.qatools:main'
'qa = qaboard.qa:main'
]
},

Expand Down
4 changes: 2 additions & 2 deletions tests/test_conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

class TestConventions(unittest.TestCase):
def test_serialize_config(self):
from qatools.conventions import serialize_config
from qaboard.conventions import serialize_config
self.assertEqual(serialize_config(['a', 'b', 'c']), 'a:b:c')
self.assertEqual(serialize_config(['a', {'b': 1}]), 'a:{"b": 1}')
self.assertEqual(serialize_config(['a', '{"b":1']), 'a:{"b":1')

def test_deserialize_config(self):
from qatools.conventions import deserialize_config
from qaboard.conventions import deserialize_config
self.assertEqual(deserialize_config('a:b:c'), ['a', 'b', 'c'])
self.assertEqual(deserialize_config('a:{"b":1}'), ['a', {'b': 1}])
self.assertEqual(deserialize_config('a:{"b":1'), ['a', '{"b":1'])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

class TestConventions(unittest.TestCase):
def test_flatten(self):
from qatools.iterators import flatten
from qaboard.iterators import flatten
self.assertEqual(list(flatten([])), [])
self.assertEqual(list(flatten([1])), [1])
self.assertEqual(list(flatten([1, [2]])), [1, 2])
self.assertEqual(list(flatten([1, [2], [3, 4, [5], [6, [7]]] ])), [1, 2, 3, 4, 5, 6, 7])
self.assertEqual(list(flatten([1, {"cde": [2, 3]} ])), [1, {"cde": [2, 3]}])

def test_resolve_aliases(self):
from qatools.iterators import resolve_aliases
from qaboard.iterators import resolve_aliases
self.assertEqual(
list(resolve_aliases(["a", "b"], {"c": ["d", "e"], "f": ["g", "h"]})),
['a', 'b']
Expand Down
9 changes: 4 additions & 5 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var config = {
tagline: "Visualize and compare algorithm results. Optimize parameters. Share results and track progress.",
// You may provide arbitrary config keys to be used as needed by your
// template. For example, if you need your repo's URL...
// repoUrl: 'https://gitlab-srv/common-infrastructure/qatools',

// scripts: [
// Add custom scripts here that would be placed in <script> tags.
Expand All @@ -40,7 +39,7 @@ var config = {
links: [
{to: 'docs/introduction', label: 'Docs', position: 'left'},
{
href: 'https://github.com/samsung/qaboard',
href: 'https://github.com/Samsung/qaboard',
label: 'GitHub.com',
position: 'right',
},
Expand Down Expand Up @@ -96,16 +95,16 @@ if (!publish_github_samsung_private && !publish_github_samsung_public) {
url: 'http://qa-docs', // Your website URL
baseUrl: '/', // Base URL for your project */
}
config.presets[0][1].editUrl = 'http://gitlab-srv/common-infrastructure/qatools/edit/master/website/';
config.presets[0][1].editUrl = 'http://gitlab-srv/common-infrastructure/qaboard/edit/master/website/';
} else {
if (publish_github_samsung_private) {
config = {
...config,
url: 'https://github.sec.samsung.net',
baseUrl: '/pages/arthur-flam/qatools/',
baseUrl: '/pages/arthur-flam/qaboard/',
githubHost: 'github.sec.samsung.net',
organizationName: 'arthur-flam',
projectName: 'qatools',
projectName: 'qaboard',
}
}
if (publish_github_samsung_public) {
Expand Down

0 comments on commit 70cab11

Please sign in to comment.