-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix conda upload #2374
Fix conda upload #2374
Conversation
7a566e9
to
fec7979
Compare
.github/workflows/workflow.yml
Outdated
restore-keys: | | ||
build-conda-${{ hashFiles('.conda/recipe.yaml') }} | ||
build-conda- | ||
key: build-conda-${{ github.sha }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
La liste des dépendances n'est-elle pas encore utile à distinguer les caches ? Le fichier recipe.yaml existe encore (malgré le passage à pyproject.toml).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vu ensemble : ici, on retirait également
restore-keys
pensant se prémunir de situations où on récupérerait un ancien cache sur des dépendances ayant évolué (cas déjà rencontré dans le passé hors conda). Mais, nous avions mal interprété cette fonction qui s'adresse à d'autres fichiers que ceux référencés danskey
. Bilan : en le supprimant, on retire une configuration inutile mais on ne se prémunit pas de l'usage d'un vieux cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai dû passer de build-conda-${{ hashFiles('.conda/recipe.yaml') }}-${{ github.sha }} à build-conda-${{ github.sha }} pour les clefs de cache car sinon il était impossible de récupérer le cache sous Windows : le hash n'était pas le même. Sûrement à cause d'un problème d'encoding ou fin de ligne.
Suite à discussion, j'ai passé toutes les étapes Conda sur des runners Windows pour mettre le hashFiles de pyproject.toml comme c'est lui qui connait la version et les dépendances.
.github/workflows/workflow.yml
Outdated
path: /tmp/conda-bld | ||
key: build-conda-${{ github.sha }} | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true # To allow restore on windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
.github/workflows/workflow.yml
Outdated
- uses: actions/checkout@v4 | ||
activate-environment: openfisca | ||
miniforge-version: latest | ||
python-version: 3.9.12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utiliser la version Python la plus récente testée ? 3.10.6 ? 🤔
Ceci dépasserait la résolution pure de l'issue visée par cette PR et aurait un impact ailleurs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fait.
run: mamba install --channel file:///tmp/conda-bld --channel openfisca openfisca-france | ||
- name: Test conda package | ||
shell: bash -l {0} | ||
run: openfisca test tests/formulas/irpp.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi réduisons-nous à un seul test ? Dans le passé, les tests permettaient de relever les erreurs de chemins de paramètres trop longs sous Windows qui pouvaient survenir à n'importe quel endroit modifié par une PR. Considérons-nous que Test max path length
suffit ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est un problème de temps de CI : tout tester prend 1 heure. On pourrait aussi mettre des tests sous forme de matrice. Cependant vu que nous ne savons pas s'il y a des utilisateurs des paquets conda, il ne semble pas nécessaire de gêner les contributeurs avec des tests supplémentaires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bilan, pour détecter les erreurs sur Windows de :
- paramètres : le script
Test max path length
(du jobtest-on-windows
à ne pas confondre avec le jobtest-path-length
exécuté sur ubuntu) vérifie le fait de ne pas dépasser la limite par défaut de longueur de path - variables, chargement du TaxBenefitSystem et bonne installation de la commande
openfisca
: l'exécution d'un seul test YAML suffit et est économe en temps de calcul ; ici on teste déjà tout ce qu'il y a dansirpp.yaml
(pas d'erreur attendue/rencontrée spécifique à des syntaxes de règles python)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merci @benoit-cty pour tout de fix de configuration !
Validé avec 3 mini points à vérifier avant merge :
- un slash en dernier commentaire qui devrait peut-être remplacer un backslash
- aligner les versions de python sur windows à 3.10.6
- et un commentaire de todo à retirer probablement
@@ -19,7 +19,7 @@ source: | |||
build: | |||
noarch: python | |||
number: 0 | |||
script: "pip install . -v" | |||
script: "pip install ." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Permet d'éviter un job rouge en sortie de CI pour log trop long.
build-conda-${{ hashFiles('.conda/recipe.yaml') }} | ||
build-conda- | ||
path: ${{ runner.temp }}\conda-bld | ||
key: build-conda-${{ hashFiles('pyproject.toml') }}-${{ github.sha }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ Pour la source unique qu'est pyproject.toml maniement pour l'information sur les dépendances.
run: mamba install --channel file:///tmp/conda-bld --channel openfisca openfisca-france | ||
- name: Test conda package | ||
shell: bash -l {0} | ||
run: openfisca test tests/formulas/irpp.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bilan, pour détecter les erreurs sur Windows de :
- paramètres : le script
Test max path length
(du jobtest-on-windows
à ne pas confondre avec le jobtest-path-length
exécuté sur ubuntu) vérifie le fait de ne pas dépasser la limite par défaut de longueur de path - variables, chargement du TaxBenefitSystem et bonne installation de la commande
openfisca
: l'exécution d'un seul test YAML suffit et est économe en temps de calcul ; ici on teste déjà tout ce qu'il y a dansirpp.yaml
(pas d'erreur attendue/rencontrée spécifique à des syntaxes de règles python)
.github/workflows/workflow.yml
Outdated
conda config --set anaconda_upload yes | ||
conda build --channel conda-forge --channel openfisca --token ${{ secrets.ANACONDA_TOKEN }} --user openfisca .conda | ||
conda install --yes anaconda-client | ||
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload --user openfisca ${{ runner.temp }}\conda-bld/noarch/openfisca-france-* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slash à vérifier ici ? : ${{ runner.temp }}\conda-bld/noarch/openfisca-france-*
À remplacer par ceci ? : ${{ runner.temp }}/conda-bld/noarch/openfisca-france-*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merci, c'est changé. Ca fonctionnait quand même car Windows supporte maintenant les deux écritures.
Checkout needed to get github.sha ci : use-mamba ci : use-mamba wip: try to understand why cache key changes use only github.sha enableCrossOsArchive remove ${{ hashFiles('.conda/recipe.yaml') Add mamba to publish Fix conda publish
Co-authored-by: sandcha <[email protected]>
Co-authored-by: sandcha <[email protected]>
Co-authored-by: sandcha <[email protected]>
e25abf4
to
b93e95f
Compare
workflow.yml
.pyproject.toml
:C:\hostedtoolcache\windows\Python\3.9.13\x64\python3.exe: can't open file 'D:\a\openfisca-france\openfisca-france\setup.py': [Errno 2] No such file or directory
Fait suite à #2369 dans laquelle il y avait des manques sur Conda. La CI a donc été mise à jour pour refléter openfisca/country-template#157
Ces changements :
Corrigent ou améliorent un calcul déjà existant.
Passage de
build-conda-${{ hashFiles('.conda/recipe.yaml') }}-${{ github.sha }}
àbuild-conda-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}
car c'est lui qui contient vraiment la version et les dépendances.Passage de toutes les étapes conda sur un runner Windows pour valider que cela fonctionne correctement et éviter des problèmes de chemin, encoding, fin de ligne...
Retrait de l'artifact qui n'était plus utilisé
Ajout d'un commentaire dans check_path_length.py pour indiquer que le script est utilisé en CI.
J'ai modifié temporairement la CI pour livrer le package en dehors de master et ça a fonctionné : https://anaconda.org/openfisca/openfisca-france Voici les logs de la CI : log
Quelques conseils à prendre en compte :
pyproject.toml
.CHANGELOG.md
.