oercommons.bulk_import¶
Bulk-import metadata from OER Commons.
Uses the OER Commons search API to fetch Open Educational Resources and
translate them into standardised OME EducationResource cards.
Results are cached locally to avoid repeated API calls.
Attributes¶
Functions¶
|
Search OER Commons and return raw search-hit dicts. |
|
Translate raw OER Commons search-hit dicts to OME EducationResource cards. |
|
Fetch OER Commons materials and return serialised OME records. |
Module Contents¶
- oercommons.bulk_import.OERCOMMONS_SEARCH_URL = 'https://oercommons.org/api/v1/materials/search'¶
- oercommons.bulk_import.DEFAULT_SEARCH_QUERY = 'python'¶
- oercommons.bulk_import.DEFAULT_BATCH_SIZE = 20¶
- oercommons.bulk_import.logger¶
- oercommons.bulk_import._plugin¶
- oercommons.bulk_import.fetch_materials(query: str = DEFAULT_SEARCH_QUERY, batch_size: int = DEFAULT_BATCH_SIZE) list[dict]¶
Search OER Commons and return raw search-hit dicts.
Each returned dict has the same shape as
Model(i.e. it contains_index,_type,_id,_score,_source) so that it can be passed directly toOERCommonsPlugin.make_metadata_card_from_json().- Args:
query: Search query string. batch_size: Maximum number of results to return.
- Returns:
A list of raw search-hit dicts.
- oercommons.bulk_import.bulk_translate(hits: list[dict]) collections.abc.Iterator[server.plugins.ome_plugin.EducationResource]¶
Translate raw OER Commons search-hit dicts to OME EducationResource cards.
Each dict should have the same shape as
Model(_index,_type,_id,_score,_source), matching the format returned by the search API and cached bybulk_import().
- oercommons.bulk_import.bulk_import(query: str = DEFAULT_SEARCH_QUERY, batch_size: int = DEFAULT_BATCH_SIZE, cache_path: pathlib.Path | None = None) list[dict]¶
Fetch OER Commons materials and return serialised OME records.
Results are cached locally so that repeated runs do not re-fetch the API.
- Args:
query: Search query string (default:
"python"). batch_size: Maximum number of results to return (default: 20). cache_path: Path to the local JSON cache file. IfNone, defaultsto
oercommons_python_materials.jsonnext to this module.- Returns:
A list of serialised
EducationResourcedicts.
- oercommons.bulk_import.here¶