softwarepub / hermes

Implementation of the HERMES workflow
https://docs.software-metadata.pub
Other
20 stars 6 forks source link

Error in harvesting metadata from codemeta.json #275

Open Aidajafarbigloo opened 3 weeks ago

Aidajafarbigloo commented 3 weeks ago

Hello,

While extracting metadata from CodeMeta files, there was an issue with finding the file path, leading to this error:

Error while executing codemeta: . contains either no or more than 1 codemeta.json file. Aborting harvesting for this metadata source..

The issue was resolved by adjusting the file path in the _get_single_codemeta function in codemeta.py, which allowed the metadata harvesting to proceed successfully.

The path was updated as follows:

From: files = glob.glob(str(path / "**" / "codemeta.json"), recursive=True)

To: files = glob.glob(str(path / "codemeta.json"), recursive=True)

If this issue is approved, I'm happy to create a pull request and apply the change.

zyzzyxdonta commented 2 weeks ago

I'm not so sure about this. This is clearly supposed to find only a single file and fail if more than one file is found. The codemeta specification doesn't seem to mention where this file is to be placed, so it makes sense to search for it. 🤔 Of course, the error message could be more specific.

(That being said, if someone touches this code, the mentioned line could be simplified to files = path.glob("**/codemeta.json". Then the bits after that need to be changed as well to handle the returned generator object correctly.)

Aidajafarbigloo commented 1 week ago

I think the error occurs when installing Hermes in an environment (e.g.: I installed it on the SMECS project) and not cloning the project. I tested both: in the second case, where I harvested from codemeta.json (a test codemeta file which I created to harvest from in the cloned project), it worked fine, but in the first case, there was the mentioned error.

zyzzyxdonta commented 1 week ago

That's because the SMECS repo (branch 114-add-codemetajson contains two codemeta.json files:

./static/codemeta.json
./codemeta.json
Aidajafarbigloo commented 1 week ago

That's right, thank you for your assistance!