Skip to content

Commit

Permalink
github: added support for extra metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandromumo authored and zzacharo committed Oct 19, 2023
1 parent e404576 commit c4e3699
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
21 changes: 11 additions & 10 deletions invenio_rdm_records/services/github/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,27 @@ def citation_metadata(self):
data = self.load_citation_file(citation_file_path)

# Load metadata from citation file and serialize it
metadata = self.load_citation_metadata(data)
return self.serialize_citation_metadata(metadata)
return self.load_citation_metadata(data)
except ValidationError as e:
# Wrap the error into CustomGitHubMetadataError() so it can be handled upstream
raise CustomGitHubMetadataError(file=citation_file_path, message=e.messages)

def serialize_citation_metadata(self, data):
"""Serializes citation data to RDM."""
if not data:
return {}
# TODO to be implemented
return data
@property
def extra_metadata(self):
"""Get extra metadata for the release."""
return self.load_extra_metadata()

def load_extra_metadata(self):
"""Get extra metadata for the release."""
return {}

def load_citation_file(self, citation_file_name):
"""Returns the citation file data."""
if not citation_file_name:
return {}

# Fetch the citation file and load it
content = self.retrieve_remote_file(citation_file_name)
content = self.rdm_release.retrieve_remote_file(citation_file_name)

data = (
yaml.safe_load(content.decoded.decode("utf-8"))
Expand All @@ -162,7 +163,7 @@ def load_citation_metadata(self, citation_data):

citation_schema = current_app.config.get("GITHUB_CITATION_METADATA_SCHEMA")

assert isinstance(citation_schema, Schema), _(
assert issubclass(citation_schema, Schema), _(
"Citation schema is needed to load citation metadata."
)

Expand Down
5 changes: 4 additions & 1 deletion invenio_rdm_records/services/github/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
class RDMGithubRelease(GitHubRelease):
"""Implement release API instance for RDM."""

metadata_cls = RDMReleaseMetadata

@property
def metadata(self):
"""Extracts metadata to create an RDM draft."""
metadata = RDMReleaseMetadata(self)
metadata = self.metadata_cls(self)
output = metadata.default_metadata
output.update(metadata.extra_metadata)
output.update(metadata.citation_metadata)
return output

Expand Down

0 comments on commit c4e3699

Please sign in to comment.