This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
Add list of pretrained models to README #246
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
"archive_file": null, | ||
"training_config": null, | ||
"overrides": null, | ||
"install_instructions": "pip install allennlp==1.0.0 allennlp-models==1.0.0", | ||
"install_instructions": "pip install allennlp==1.0.0 allennlp-models==1.0.0" | ||
}, | ||
"model_details": { | ||
"description": null, | ||
|
@@ -21,7 +21,7 @@ | |
"paper": null, | ||
"citation": null, | ||
"license": null, | ||
"contact": "[email protected]", | ||
"contact": "[email protected]" | ||
}, | ||
"intended_use": { | ||
"primary_uses": null, | ||
|
@@ -57,4 +57,4 @@ | |
"model_ethical_considerations": { | ||
"ethical_considerations": null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Run this script to update the list of pre-trained models in the README based on the current model cards. | ||
""" | ||
|
||
from typing import List | ||
import json | ||
import glob | ||
|
||
|
||
AUTO_GENERATED_SECTION_START = "<!-- This section is automatically generated" | ||
AUTO_GENERATED_SECTION_END = "<!-- End automatically generated section -->" | ||
|
||
|
||
def main(): | ||
with open("README.md") as readme_file: | ||
readme_lines = readme_file.readlines() | ||
|
||
section_start_idx = next( | ||
(i for i, l in enumerate(readme_lines) if l.startswith(AUTO_GENERATED_SECTION_START)) | ||
) | ||
section_end_idx = next( | ||
(i for i, l in enumerate(readme_lines) if l.startswith(AUTO_GENERATED_SECTION_END)) | ||
) | ||
|
||
model_list: List[str] = ["\n"] | ||
for model_card_path in sorted(glob.glob("allennlp_models/modelcards/*.json")): | ||
if model_card_path.endswith("modelcard-template.json"): | ||
continue | ||
with open(model_card_path) as model_card_file: | ||
model_card = json.load(model_card_file) | ||
model_id = model_card["id"] | ||
description = model_card["model_details"]["short_description"] | ||
model_list.append( | ||
f"- [`{model_id}`](https://github.com/allenai/allennlp-models/tree/main/" | ||
f"{model_card_path}) - {description}\n" | ||
) | ||
model_list.append("\n") | ||
|
||
readme_lines = ( | ||
readme_lines[: section_start_idx + 1] + model_list + readme_lines[section_end_idx:] | ||
) | ||
|
||
with open("README.md", "w") as readme_file: | ||
readme_file.writelines(readme_lines) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The template should probably say
2.2.0
by now.