Pycograph logo

Pycograph

Examples

Return every node

Project: Docker Compose

The more relationships a node has, the bigger it's represented.

GRAPH.QUERY "compose" 
"MATCH (n) RETURN n"

The biggest nodes are: compose.config.config, tests.integration.service_test.ServiceTest, tests.helpers.build_config_details

Return every non-test object

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (n {is_test_object: False}) RETURN n"

up: the function behind the docker-compose up command

Project: Docker Compose

A query returning exactly one node using the unique full_name property. Double-click on the node to display all its relationships.

GRAPH.QUERY "compose" 
"MATCH (up: function {full_name: 'compose.cli.main.TopLevelCommand.up'}) 
RETURN up"

up and its calls relationships

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (f: function {full_name: 'compose.cli.main.TopLevelCommand.up'}) - [c: calls] -> (n) 
RETURN f, n"

up and its calls relationships excluding calls to self

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (f: function {full_name: 'compose.cli.main.TopLevelCommand.up'}) - [c: calls] -> (n) 
WHERE c.reference_name <> 'self' 
RETURN f, n"

up calls and where are those called functions located

Project: Docker Compose

Which functions and classes does compose.cli.main.TopLevelCommand.up call and where are they located? Calls within the class TopLevelCommand are excluded.

GRAPH.QUERY "compose" 
"MATCH (up: function {full_name: 'compose.cli.main.TopLevelCommand.up'}) 
- [c: calls] -> (n) <- [c2: contains] - (owner) 
WHERE c.reference_name <> 'self' 
RETURN up, n, owner"

up is mainly calling functions located in its own module compose.cli.main

The most often called function

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (x) - [c:calls] -> (n:function) RETURN n, COUNT(x) as call_count 
ORDER BY call_count desc"

compose.config.load: 162, compose.project.Project.from_config: 71, compose.config.config.merge_service_dicts: 61

Functions calling compose.config.config.load

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (x) 
- [c:calls] -> (n:function {full_name: 'compose.config.config.load'}) 
RETURN x"

162 calls: 155 test functions, 5 test helper functions, 2 functions from the production code.

Testing styles: unittest vs pytest

Project: Docker Compose

Where are the test functions located? In classes or in modules directly?

GRAPH.QUERY "compose" 
"MATCH (t) 
- [c: contains] -> 
(tf: test_function) 
RETURN t, tf"

83 test classes, 5 modules containing directly a test function.

Test functions calling each other

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (tf: test_function) 
- [c: calls] -> 
(other_tf: test_function) RETURN tf, other_tf"

1 such case found: tests.acceptance.cli_test.CLITestCase.test_build_log_level -> tests.acceptance.cli_test.CLITestCase.test_env_file_relative_to_compose_file

Function calls in and between packages

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (called_package: package) 
- [:contains*] -> (f: function) <- [:calls] - (caller: function) <- [:contains*] 
(caller_package: package) 
RETURN caller_package, called_package, count(f) as call_count 
ORDER BY call_count desc"

compose => compose: 372, compose.config => compose.config: 192, compose.cli => compose.cli: 147, compose.cli => compose.config: 13, compose.config => compose: 12

Function calls only between packages

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (called_package: package) 
- [:contains*] -> (f: function) <- [:calls] - (caller: function) <- [:contains*] 
(caller_package: package) 
WHERE (caller_package.full_name <> called_package.full_name) 
RETURN caller_package, called_package, count(f) as call_count 
ORDER BY call_count desc"

compose.cli => compose.config: 13, compose.config => compose: 12, compose => compose.config: 10, compose.cli => compose: 6, compose => compose.cli: 2

Calls to cli from other packages

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (called_package: package 
{full_name: 'compose.cli'}) 
- [:contains*] -> (f: function) <- [:calls] - (caller: function) <- [:contains*] - (caller_package: package)  
WHERE (caller_package.full_name <> called_package.full_name) 
RETURN f, caller_package, caller"

2 such cases found, both for compose.cli.utils.binarystr_to_unicode: compose.service.Service.create_container, compose.service.Service.start_container

build vs run

Project: Docker Compose

Functions called by the Docker Compose top level commands build and run

GRAPH.QUERY "compose" 
"MATCH (command: function) - [c: calls] -> (n) <- [c2: contains] - (owner) 
WHERE command.full_name in ['compose.cli.main.TopLevelCommand.build', 'compose.cli.main.TopLevelCommand.run'] 
RETURN command, n, owner"

Integration test package overview

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (tm: test_module) - [c: contains] -> (n) 
WHERE (tm.test_type='integration') 
RETURN tm, n"

Test functions calling a helper from another test type

Project: Docker Compose
GRAPH.QUERY "compose" 
"MATCH (tf: test_function) - [c:calls] -> (th: test_helper_function) 
WHERE (tf.test_type <> th.test_type and th.test_type <> '') 
RETURN tf, th"

up vs down

Project: Docker Compose

Functions called by the Docker Compose top level commands up and down

GRAPH.QUERY "compose" 
"MATCH (command: function) - [c: calls] -> (n) <- [c2: contains] - (owner) 
WHERE command.full_name in ['compose.cli.main.TopLevelCommand.up', 'compose.cli.main.TopLevelCommand.down'] 
RETURN command, n, owner"

down calls a small subset of functions up is calling plus compose.cli.main.image_type_from_opt

up vs run

Project: Docker Compose

Functions called by the Docker Compose top level commands up and run

GRAPH.QUERY "compose" 
"MATCH (command: function) - [c: calls] -> (n) <- [c2: contains] - (owner) 
WHERE command.full_name in ['compose.cli.main.TopLevelCommand.up', 'compose.cli.main.TopLevelCommand.run'] 
RETURN command, n, owner"

run calls a small subset of functions up is calling plus compose.cli.main.build_one_off_container_options and compose.cli.main.run_one_off_container