Skip to content

Commit

Permalink
feat: don't include from arrays in tree
Browse files Browse the repository at this point in the history
as the backend doesn't need these anymore,
and it reduces the result json size by factor of ~3x
  • Loading branch information
michael-go committed Apr 26, 2018
1 parent d55bc84 commit 3023d60
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 102 deletions.
8 changes: 0 additions & 8 deletions plug/pip_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def create_tree_of_packages_dependencies(dist_tree, packages_names, req_file_pat
:rtype: dict
"""
DEPENDENCIES = 'dependencies'
FROM = 'from'
VERSION = 'version'
NAME = 'name'
VERSION_SEPARATOR = '@'
Expand Down Expand Up @@ -60,8 +59,6 @@ def create_children_recursive(root_package, key_tree, ancestors):
child_package = {
NAME: child_dist.project_name,
VERSION: child_dist.installed_version,
FROM: root_package[FROM] +
[child_dist.key + VERSION_SEPARATOR + child_dist.installed_version]
}

create_children_recursive(child_package, key_tree, ancestors)
Expand All @@ -76,7 +73,6 @@ def create_dir_as_root():
NAME: name,
VERSION: DIR_VERSION,
DEPENDENCIES: {},
FROM: [name + VERSION_SEPARATOR + DIR_VERSION], DEPENDENCIES: {},
PACKAGE_FORMAT_VERSION: 'pip:0.0.1'
}
return dir_as_root
Expand All @@ -85,10 +81,6 @@ def create_package_as_root(package, dir_as_root):
package_as_root = {
NAME: package.project_name.lower(),
VERSION: package._obj._version,
FROM: ["{}{}{}".format(
dir_as_root[NAME], VERSION_SEPARATOR, dir_as_root[VERSION])] +
["{}{}{}".format(
package.project_name.lower(), VERSION_SEPARATOR, package._obj._version)]
}
return package_as_root
dir_as_root = create_dir_as_root()
Expand Down
94 changes: 0 additions & 94 deletions test/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,20 @@ test('inspect', function (t) {
t.ok(pkg, 'package');
t.equal(pkg.name, 'pip-app', 'name');
t.equal(pkg.version, '0.0.0', 'version');
// t.equal(pkg.full, 'pip-app@0.0.0', 'full'); // do we need this?
t.same(pkg.from, ['pip-app@0.0.0'], 'from self');
t.end();
});

t.test('package dependencies', function (t) {
t.same(pkg.dependencies.django, {
name: 'django',
version: '1.6.1',
from: [
'pip-app@0.0.0',
'django@1.6.1',
],
}, 'django looks ok');

t.match(pkg.dependencies.jinja2, {
name: 'jinja2',
version: '2.7.2',
from: [
'pip-app@0.0.0',
'jinja2@2.7.2',
],
dependencies: {
markupsafe: {
from: [
'pip-app@0.0.0',
'jinja2@2.7.2',
/markupsafe@.+$/,
],
name: 'markupsafe',
version: /.+$/,
},
Expand All @@ -75,39 +60,21 @@ test('inspect', function (t) {
t.match(pkg.dependencies['python-etcd'], {
name: 'python-etcd',
version: '0.4.5',
from: [
'pip-app@0.0.0',
'python-etcd@0.4.5',
],
dependencies: {
dnspython: {
name: 'dnspython',
version: /.+$/,
from: [
'pip-app@0.0.0',
'python-etcd@0.4.5',
/dnspython@.+$/,
],
},
urllib3: {
name: 'urllib3',
version: /.+$/,
from: [
'pip-app@0.0.0',
'python-etcd@0.4.5',
/urllib3@.+$/,
],
},
},
}, 'python-etcd is ok');

t.match(pkg.dependencies['django-select2'], {
name: 'django-select2',
version: '6.0.1',
from: [
'pip-app@0.0.0',
'django-select2@6.0.1',
],
dependencies: {
'django-appconf': {
name: 'django-appconf',
Expand All @@ -118,10 +85,6 @@ test('inspect', function (t) {
t.match(pkg.dependencies['irc'], {
name: 'irc',
version: '16.2',
from: [
"pip-app@0.0.0",
"irc@16.2"
],
dependencies: {
'more-itertools': {},
'jaraco.functools': {},
Expand All @@ -141,10 +104,6 @@ test('inspect', function (t) {
t.match(pkg.dependencies['testtools'], {
name: 'testtools',
version: '2.3.0',
from: [
"pip-app@0.0.0",
"testtools@2.3.0"
],
dependencies: {
'pbr': {},
'extras': {},
Expand Down Expand Up @@ -200,66 +159,39 @@ test('transitive dep not installed, but with allowMissing option', function (t)
t.equal(pkg.name, 'pip-app', 'name');
t.equal(pkg.version, '0.0.0', 'version');
// t.equal(pkg.full, 'pip-app@0.0.0', 'full'); // do we need this?
t.same(pkg.from, ['pip-app@0.0.0'], 'from self');
t.end();
});

t.test('package dependencies', function (t) {
t.same(pkg.dependencies.django, {
name: 'django',
version: '1.6.1',
from: [
'pip-app@0.0.0',
'django@1.6.1',
],
}, 'django looks ok');

t.match(pkg.dependencies.jinja2, {
name: 'jinja2',
version: '2.7.2',
from: [
'pip-app@0.0.0',
'jinja2@2.7.2',
],
dependencies: {},
}, 'jinja2 looks ok');

t.match(pkg.dependencies['python-etcd'], {
name: 'python-etcd',
version: '0.4.5',
from: [
'pip-app@0.0.0',
'python-etcd@0.4.5',
],
dependencies: {
dnspython: {
name: 'dnspython',
version: /.+$/,
from: [
'pip-app@0.0.0',
'python-etcd@0.4.5',
/dnspython@.+$/,
],
},
urllib3: {
name: 'urllib3',
version: /.+$/,
from: [
'pip-app@0.0.0',
'python-etcd@0.4.5',
/urllib3@.+$/,
],
},
},
}, 'python-etcd is ok');

t.match(pkg.dependencies['django-select2'], {
name: 'django-select2',
version: '6.0.1',
from: [
'pip-app@0.0.0',
'django-select2@6.0.1',
],
dependencies: {
'django-appconf': {
name: 'django-appconf',
Expand Down Expand Up @@ -305,7 +237,6 @@ test('deps not installed, but with allowMissing option', function (t) {
t.ok(pkg, 'package');
t.equal(pkg.name, 'pip-app-deps-not-installed', 'name');
t.equal(pkg.version, '0.0.0', 'version');
t.same(pkg.from, ['pip-app-deps-not-installed@0.0.0'], 'from self');
t.end();
});
});
Expand Down Expand Up @@ -336,18 +267,10 @@ test('package name differs from requirement', function (t) {
.then(function (result) {
var pkg = result.package;
t.same(pkg.dependencies['dj-database-url'], {
from: [
'pip-app-deps-with-dashes@0.0.0',
'dj-database-url@0.4.2',
],
name: 'dj-database-url',
version: '0.4.2',
}, 'dj-database-url looks ok');
t.same(pkg.dependencies['posix-ipc'], {
from: [
'pip-app-deps-with-dashes@0.0.0',
'posix-ipc@1.0.0',
],
name: 'posix-ipc',
version: '1.0.0',
}, 'posix-ipc looks ok');
Expand All @@ -368,10 +291,6 @@ test('package depends on platform', function (t) {
var pkg = result.package;
t.notOk(pkg.dependencies.pypiwin32, 'win32 dep ignored');
t.same(pkg.dependencies['posix-ipc'], {
from: [
'pip-app-deps-conditional@0.0.0',
'posix-ipc@1.0.0',
],
name: 'posix-ipc',
version: '1.0.0',
}, 'posix-ipc looks ok');
Expand All @@ -393,10 +312,6 @@ test('editables ignored', function (t) {
t.notOk(pkg.dependencies['simple'], 'editable dep ignored');
t.notOk(pkg.dependencies['sample'], 'editable subdir dep ignored');
t.same(pkg.dependencies['posix-ipc'], {
from: [
'pip-app-deps-editable@0.0.0',
'posix-ipc@1.0.0',
],
name: 'posix-ipc',
version: '1.0.0',
}, 'posix-ipc looks ok');
Expand Down Expand Up @@ -429,27 +344,18 @@ test('deps withs options', function (t) {
t.ok(pkg, 'package');
t.equal(pkg.name, 'pip-app-with-options', 'name');
t.equal(pkg.version, '0.0.0', 'version');
t.same(pkg.from, ['pip-app-with-options@0.0.0'], 'from self');
t.end();
});

t.test('package dependencies', function (t) {
t.match(pkg.dependencies.markupsafe, {
name: 'markupsafe',
version: '1.0',
from: [
'pip-app-with-options@0.0.0',
'markupsafe@1.0',
],
}, 'MarkupSafe looks ok');

t.match(pkg.dependencies.dnspython, {
name: 'dnspython',
version: '1.13.0',
from: [
'pip-app-with-options@0.0.0',
'dnspython@1.13.0',
],
}, 'dnspython looks ok');

t.end();
Expand Down

0 comments on commit 3023d60

Please sign in to comment.