[Debian-pan-maintainers] Progress Report
RAHLI Oussama
oussama.rahli at synchrotron-soleil.fr
Fri Aug 9 17:30:27 BST 2024
Hello everyone,
This week, with the help of Mr. PICCA, we created integration tests for the orange3 project.
conda-autodep8 : This Python script automatically generates a shell script to configure and test a Conda environment based on a YAML configuration file “meta.yaml”. It reads this file to extract the necessary Conda commands and Python modules for testing. The script then creates an executable shell script that sets up the environment, runs the commands, and tests the Python imports across various available Python versions.
Content of conda-autodep8:
#!/usr/bin/env python3
import yaml
import os
import sys
import subprocess
def generate_conda(commands, imports, filename="conda_test"):
with open(filename, 'w') as f:
f.write('#!/bin/sh -ex\n\n')
f.write('PWD=$(pwd)\n\n')
f.write('cd ${AUTOPKGTEST_TMP}\n\n')
# Ajouter les commandes conda
f.write('# conda commands\n')
for cmd in commands:
f.write(f"{cmd}\n")
# Ajouter les imports
f.write('\n# conda imports\n')
f.write('py_script="\n')
for imp in imports:
f.write(f"import {imp}\n")
f.write('"\n')
f.write('for py in $(py3versions --supported 2>/dev/null); do\n')
f.write(' echo "Testing with $py:"\n')
f.write(' $py -c "$py_script"\n')
f.write('done\n')
def extract_test(content: str) -> str:
cont = content.split('\n')
cont = '\n'.join([c for c in cont if '{%' not in c and '{{' not in c])
print(cont)
data = yaml.safe_load(cont)
print(data)
test_data = data.get('test', {})
return yaml.dump(test_data, default_flow_style=False)
def main(meta_yaml: str = None):
if meta_yaml is None:
meta_yaml = '../../conda-recipe/meta.yaml'
else:
if len(sys.argv) != 2:
print("Usage: conda <meta.yaml>")
sys.exit(1)
meta_yaml = sys.argv[1]
print(meta_yaml)
if not os.path.exists(meta_yaml):
print(f"Erreur : le fichier {meta_yaml} n'existe pas.")
sys.exit(1)
with open(meta_yaml) as f:
content = f.read()
test_yaml = extract_test(content)
test_data = yaml.safe_load(test_yaml)
# commands
commands = test_data.get('commands', [])
# imports
imports = test_data.get('imports', [])
generate_conda(commands, imports)
if __name__ == "__main__":
main()
gui: This script is used to execute the command “orange-canvas --help” with a time constraint. If the command is interrupted by the timeout, the script considers this situation acceptable and exits successfully.
Content of gui:
#!/bin/sh -ex
timeout --preserve-status 5s orange-canvas --help
ec=$?
if [ $ec -eq 143 ]; then
echo "trapped status 143 and return success"
exit 0;
else
exit $ec;
f i
Best regards,
Oussama RAHLI
Student at INSA Rennes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-pan-maintainers/attachments/20240809/de16c5fb/attachment-0001.htm>
More information about the Debian-pan-maintainers
mailing list