Skip to content
Snippets Groups Projects
Commit 9f7b39a5 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

black

parent d827f12d
No related branches found
No related tags found
No related merge requests found
......@@ -11,38 +11,38 @@ FILE_PATH = os.path.dirname(os.path.realpath(__file__))
def read_yaml(path):
with open(path, 'rt') as f:
with open(path, "rt") as f:
data = yaml.safe_load(f)
return data
def write_yaml(path, data):
with open(path, 'wt') as f:
with open(path, "wt") as f:
yaml.safe_dump(data, f, default_flow_style=False)
def extract_github_tar_gz(data):
for entry in data:
if 'tar' not in entry:
if "tar" not in entry:
continue
tar = entry['tar']
if 'github.com' not in tar['uri'] or not tar['uri'].endswith('.tar.gz'):
tar = entry["tar"]
if "github.com" not in tar["uri"] or not tar["uri"].endswith(".tar.gz"):
continue
version = tar['uri'][tar['uri'].rindex('/') + 1: -len('.tar.gz')]
if not tar['version'].endswith(version):
version = tar["uri"][tar["uri"].rindex("/") + 1 : -len(".tar.gz")]
if not tar["version"].endswith(version):
continue
yield tar, version
def download_file(url, path):
r = requests.get(url, stream=True)
with open(path, 'wb') as fd:
with open(path, "wb") as fd:
for chunk in r.iter_content(chunk_size=128):
fd.write(chunk)
def check_tar_gz_version(path, version):
with tarfile.open(path, 'r:gz') as f:
with tarfile.open(path, "r:gz") as f:
name = f.getmembers()[0].name
return name.endswith(version)
......@@ -51,19 +51,19 @@ def github_bug_workaround(rosinstall, rosinstall_out):
tmp_dir = tempfile.mkdtemp()
data = read_yaml(rosinstall)
for entry, version in extract_github_tar_gz(data):
file_name = os.path.join(tmp_dir, 'tmp.tar.gz')
download_file(entry['uri'], file_name)
file_name = os.path.join(tmp_dir, "tmp.tar.gz")
download_file(entry["uri"], file_name)
has_version = check_tar_gz_version(file_name, version)
os.remove(file_name)
if not has_version:
entry['version'] = entry['version'][: -(len(version) + 1)]
entry["version"] = entry["version"][: -(len(version) + 1)]
write_yaml(rosinstall_out, data)
shutil.rmtree(tmp_dir)
if __name__ == '__main__':
rosinstall = os.environ['ROS_DISTRO'] + '-ros_comm.rosinstall'
rosinstall_out = rosinstall + '.new'
if __name__ == "__main__":
rosinstall = os.environ["ROS_DISTRO"] + "-ros_comm.rosinstall"
rosinstall_out = rosinstall + ".new"
github_bug_workaround(rosinstall, rosinstall_out)
......@@ -5,78 +5,82 @@ from json import load
# import requests
with open('targets') as f:
with open("targets") as f:
TARGETS = [target.strip() for target in f.readlines()]
with open('all.Dockerfile') as f:
with open("all.Dockerfile") as f:
TEMPLATE = f.read()
ALL = './memmos.laas.fr:5000/gepetto/buildfarm/all'
CONF = '>> /opt/openrobots/etc/robotpkg.conf\n'
CACHE = '--mount=type=cache,target=/root/robotpkg/distfiles'
ALL = "./memmos.laas.fr:5000/gepetto/buildfarm/all"
CONF = ">> /opt/openrobots/etc/robotpkg.conf\n"
CACHE = "--mount=type=cache,target=/root/robotpkg/distfiles"
COMMENTED = {
'sot-hrprtc-hrp2': 'too old',
'sot-hrp2-v3': 'too old',
'hrp2-14-description': 'private',
'pyrene-motions': 'broken',
'openhrp3-simulator-wo-rtm': 'it cant find QMetaType from gepetto/viewer/config-osg.h',
'hpp-doc': 'not relevant',
'example-adder': 'tmp',
"sot-hrprtc-hrp2": "too old",
"sot-hrp2-v3": "too old",
"hrp2-14-description": "private",
"pyrene-motions": "broken",
"openhrp3-simulator-wo-rtm": "it cant find QMetaType from gepetto/viewer/config-osg.h",
"hpp-doc": "not relevant",
"example-adder": "tmp",
}
COMMENTED_TARGETS = {}
NO_TESTS = [
'rqt-dynamic-graph',
'py-sot-talos-balance',
'tiago-robot',
'talos-metapkg-ros-control-sot',
'py-multicontact-api'
'hpp-rbprm'
"rqt-dynamic-graph",
"py-sot-talos-balance",
"tiago-robot",
"talos-metapkg-ros-control-sot",
"py-multicontact-api" "hpp-rbprm",
]
NO_TESTS_TARGETS = {
'hpp-constraints': ['archlinux', 'stretch', '16.04'],
'hpp-core': ['archlinux', 'stretch', '16.04'],
'py-hpp-corbaserver': ['stretch', '16.04'],
'hpp-pinocchio': ['stretch', '16.04'],
'py-hpp-rbprm-corba': ['fedora34'],
}
HIDDEN_DEPS = {
"hpp-constraints": ["archlinux", "stretch", "16.04"],
"hpp-core": ["archlinux", "stretch", "16.04"],
"py-hpp-corbaserver": ["stretch", "16.04"],
"hpp-pinocchio": ["stretch", "16.04"],
"py-hpp-rbprm-corba": ["fedora34"],
}
HIDDEN_DEPS = {}
# RAINBOARD_DATA = requests.get('https://rainboard.laas.fr/projects/ordered').json()['ret']
with open('ordered') as f:
RAINBOARD_DATA = load(f)['ret']
with open("ordered") as f:
RAINBOARD_DATA = load(f)["ret"]
for target in TARGETS:
user = 'home/user' if target == 'archlinux' else 'root'
user = "home/user" if target == "archlinux" else "root"
path = ALL
if target in ['ferrum']:
path = path.replace('memmos.laas.fr:5000', 'gitlab.laas.fr:4567')
with (Path(path) / target / 'Dockerfile').open('w') as f:
f.write('# syntax=docker/dockerfile:experimental\n')
f.write(f'FROM memmos.laas.fr:5000/gepetto/buildfarm/robotpkg:{target} as main\n\n')
if target in ["ferrum"]:
path = path.replace("memmos.laas.fr:5000", "gitlab.laas.fr:4567")
with (Path(path) / target / "Dockerfile").open("w") as f:
f.write("# syntax=docker/dockerfile:experimental\n")
f.write(
f"FROM memmos.laas.fr:5000/gepetto/buildfarm/robotpkg:{target} as main\n\n"
)
f.write(TEMPLATE)
for category, project, _, deps in RAINBOARD_DATA:
f.write(f'\nFROM main as {project}\n')
f.write(f"\nFROM main as {project}\n")
for dep in deps + HIDDEN_DEPS.get(project, []):
f.write(f'COPY --from={dep} /opt/openrobots /opt/openrobots\n')
f.write(f'\nWORKDIR /{user}/robotpkg/{category}/{project}\n')
if project == 'pinocchio':
f.write("RUN sed -i 's/-DBUILD_TESTING=OFF/-DBUILD_TESTING=ON/' Makefile\n")
f.write(f"COPY --from={dep} /opt/openrobots /opt/openrobots\n")
f.write(f"\nWORKDIR /{user}/robotpkg/{category}/{project}\n")
if project == "pinocchio":
f.write(
"RUN sed -i 's/-DBUILD_TESTING=OFF/-DBUILD_TESTING=ON/' Makefile\n"
)
if project in COMMENTED:
f.write(f'# TODO {COMMENTED[project]}\n#')
f.write(f"# TODO {COMMENTED[project]}\n#")
if project in COMMENTED_TARGETS and target in COMMENTED_TARGETS[project]:
f.write(f'# TODO not on {target}\n#')
f.write(f"# TODO not on {target}\n#")
if project in NO_TESTS:
f.write('# TODO test fail\n')
f.write("# TODO test fail\n")
if project in NO_TESTS_TARGETS and target in NO_TESTS_TARGETS[project]:
f.write(f'# TODO test fail on {target}\n')
f.write(f'RUN {CACHE} sccache -s && make install')
if project not in NO_TESTS and (project not in NO_TESTS_TARGETS
or target not in NO_TESTS_TARGETS[project]):
f.write(' && build=$(make show-var VARNAME=CONFIGURE_DIRS)')
f.write(' && pushd $(make show-var VARNAME=WRKSRC) && pushd $build')
f.write(' && make test && popd && popd')
f.write(f' && make clean # {project}\n')
f.write(f"# TODO test fail on {target}\n")
f.write(f"RUN {CACHE} sccache -s && make install")
if project not in NO_TESTS and (
project not in NO_TESTS_TARGETS
or target not in NO_TESTS_TARGETS[project]
):
f.write(" && build=$(make show-var VARNAME=CONFIGURE_DIRS)")
f.write(" && pushd $(make show-var VARNAME=WRKSRC) && pushd $build")
f.write(" && make test && popd && popd")
f.write(f" && make clean # {project}\n")
f.write('\nFROM main as final\n')
f.write("\nFROM main as final\n")
for _, project, _, _ in RAINBOARD_DATA:
f.write(f'COPY --from={project} /opt/openrobots /opt/openrobots\n')
f.write(f"COPY --from={project} /opt/openrobots /opt/openrobots\n")
%% Cell type:code id: tags:
``` python
from pathlib import Path
from example_robot_data.path import EXAMPLE_ROBOT_DATA_MODEL_DIR
import pinocchio as pin
from pinocchio.visualize import MeshcatVisualizer
```
%% Cell type:code id: tags:
``` python
model_path = Path(EXAMPLE_ROBOT_DATA_MODEL_DIR)
mesh_dir = model_path
urdf_filename = "talos_reduced.urdf"
urdf_model_path = model_path / "talos_data/robots" / urdf_filename
```
%% Cell type:code id: tags:
``` python
model, collision_model, visual_model = pin.buildModelsFromUrdf(str(urdf_model_path), str(mesh_dir), pin.JointModelFreeFlyer())
model, collision_model, visual_model = pin.buildModelsFromUrdf(
str(urdf_model_path), str(mesh_dir), pin.JointModelFreeFlyer()
)
```
%% Cell type:code id: tags:
``` python
viz = MeshcatVisualizer(model, collision_model, visual_model)
```
%% Cell type:code id: tags:
``` python
viz.initViewer(open=True)
```
%% Output
You can open the visualizer by visiting the following URL:
http://127.0.0.1:7000/static/
%% Cell type:code id: tags:
``` python
viz.loadViewerModel()
```
%% Cell type:code id: tags:
``` python
q0 = pin.neutral(model)
```
%% Cell type:code id: tags:
``` python
viz.display(q0)
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -6,8 +6,8 @@ from pathlib import Path
from tabulate import tabulate
LOGDIR = Path('logs')
with open('targets') as f:
LOGDIR = Path("logs")
with open("targets") as f:
TARGETS = [line.strip() for line in f]
......@@ -15,33 +15,39 @@ def parse_log(path):
results = {}
with path.open() as f:
for line in f:
if 'docker build' in line:
if "docker build" in line:
try:
results[':'.join(re.search(' -t ([^ ]+) ', line).groups()[0].split(':')[:2])] = False
results[
":".join(
re.search(" -t ([^ ]+) ", line).groups()[0].split(":")[:2]
)
] = False
except Exception:
print(f'fail in {path}: {line} do not contain a valid tag')
if 'Successfully tagged' in line:
results[':'.join(line.split()[2].split(':')[:2])] = True
print(f"fail in {path}: {line} do not contain a valid tag")
if "Successfully tagged" in line:
results[":".join(line.split()[2].split(":")[:2])] = True
return results
def show_result(results, target, tag):
if tag not in results[target]:
return ' '
return ' .' if results[target][tag] else ' x'
return " "
return " ." if results[target][tag] else " x"
def get_tags(results):
# TODO
return sorted(set(sum((list(results[target].keys()) for target in TARGETS), []))) # TODO
return sorted(
set(sum((list(results[target].keys()) for target in TARGETS), []))
) # TODO
if __name__ == '__main__':
if __name__ == "__main__":
results = {}
table = [[''] + TARGETS]
table = [[""] + TARGETS]
for target in TARGETS:
results[target] = parse_log(LOGDIR / f'build_{target}')
results[target] = parse_log(LOGDIR / f"build_{target}")
for tag in get_tags(results):
table += [[tag] + [show_result(results, target, tag) for target in TARGETS]]
......
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