Skip to content
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 on plug-ins who moved from setup.json to pyproject.toml but haven't updated aiida-registry about this #309

Merged

Conversation

khsrali
Copy link
Contributor

@khsrali khsrali commented Mar 19, 2024

Regrading issue raised by @giovannipizzi of appearing W002 for functioning plug-ins.

There are 26 packages that moved from setup.json to pyproject.toml but haven't updated aiida-registry about this. Currently, 9 of these packages cause W002 to appear on aiida-registry webpage.
With this commit, errors caused for this reason should disappear.

Note for future: we (I and @unkcpz) think it's better to have an automated action such, if it doesn't find the info in the plugin_info url, looks for other possibilities, like pyproject.toml, setup.cfg, etc. and once found it could fire a PR for that. If not, drop an email to the responsible plug-in developers about this.

…oning plug-ins.

There are 26 packages that moved from `setup.json` to `pyproject.toml` but haven't updated aiida-registry about this.
Currently, 9 of these packages cause W002 to appear on aiida-registry webpage.
With this commit, errors caused for this reason should disappear.
Note for future: we (I and @unkcpz) think it's better to have an automated action such, if it doesn't find the info in the plugin_info url, looks for other possibilities, like pyproject.toml, setup.cfg, etc. and once found it could fire a PR for that. If not, drop an email to the responsible plug-in developers about this.
@unkcpz
Copy link
Member

unkcpz commented Mar 19, 2024

@khsrali thanks!
How do you make the change? If the changes are made automatically by script, you can easily convert it to a GHA as such:
https://github.com/unkcpz/aiida-core-i18n/blob/cf54fcdef9dc8cb6ac04308dcb704f1f00e12b5c/.github/workflows/ci-update-pot.yml#L46-L55

I am looking forward to see the problem is solved once for all and don't need to maintain for long time in the future.

Copy link

github-actions bot commented Mar 19, 2024

PR Preview Action v1.4.7
🚀 Deployed preview to https://aiidateam.github.io/aiida-registry/pr-preview/pr-309/
on branch gh-pages at 2024-03-20 12:55 UTC

@khsrali
Copy link
Contributor Author

khsrali commented Mar 19, 2024

Thanks @unkcpz for sharing the link! I think it's very useful.
yes with a script, I'll follow to make a GHA, on that.

Anyways, for a quick check on deployed preview, here is the list of 9 plug-ins with appearing W002:
aiida-ddec
aiida-flexpart
aiida-environ
aiida-lammps
aiida-nanotech-empa
aiida-nims-scheduler
aiida-yascheduler
aiida-z2pack
aiida-fenics

@khsrali khsrali requested a review from unkcpz March 19, 2024 13:54
Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, can you then just update the 9 plugins and leave other plugins unchanged for testing the future CI? Also maybe provide the script (can paste as a comment if not too long), in case forget in future.

@khsrali
Copy link
Contributor Author

khsrali commented Mar 20, 2024

Hi @unkcpz ,
ok updated, when converting to GHA, we don't need that uglyKEYcheck anymore. so i don't bring it here.

import yaml
import requests
from uglyKEYcheck import search_in_url

maindomain = "https://aiidateam.github.io/aiida-registry/"

def load_yaml_file(file_path):
    with open(file_path, 'r') as file:
        return yaml.safe_load(file)

def save_yaml_file(file_path, data):
    with open(file_path, 'w') as file:
        yaml.safe_dump(data, file, sort_keys=False)

def check_if_toml(url):
    new_url = '/'.join(url.split('/')[:-1]) + '/pyproject.toml'
    response = requests.head(new_url, timeout=10)
    if response.status_code == 404:
        return None
    else:
        return new_url

def check_urls(data):
    updates = False
    for plugin, info in data.items():
        url = info.get("plugin_info")
        if url:
            try:
                response = requests.get(url, allow_redirects=True)
                if response.status_code == 404:
                    new_url = check_if_toml(url)
                    if new_url:
                        print(f"{plugin}: returned a 404 status. But *pyproject.toml* detected!")
                        if search_in_url(maindomain+plugin, 'W002'):
                            data[plugin]["plugin_info"] = new_url
                            updates = True
                            print(plugin, ' updated')
                    else:
                        print(f"{plugin}: returned a 404 status. No *pyproject.toml* detected.")
                else:
                    pass
            except requests.RequestException as e:
                print(f"Error checking {plugin}: {url}. Error: {e}")
    return updates

yaml_file_path = 'plugins.yaml'

data = load_yaml_file(yaml_file_path)
if check_urls(data):
    save_yaml_file('plugins-out.yaml', data)
    print("YAML file updated.")

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One entry seems not correctly fixed.

plugins.yaml Outdated Show resolved Hide resolved
khsrali and others added 2 commits March 20, 2024 11:51
Change of maintainer: for aiida-fenics

Co-authored-by: Jusong Yu <jusong.yeu@gmail.com>
plugins.yaml Outdated Show resolved Hide resolved
Co-authored-by: Jusong Yu <jusong.yeu@gmail.com>
Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @khsrali All good.

@khsrali
Copy link
Contributor Author

khsrali commented Mar 20, 2024

Thanks @unkcpz for your quick & nice review

@khsrali khsrali merged commit 1539add into aiidateam:master Mar 20, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants