Skip to content

Commit

Permalink
Merge pull request #10 from idn-au/feature/files-changed-action-fix
Browse files Browse the repository at this point in the history
Uploading scores, small action fix
  • Loading branch information
jamiefeiss authored Jul 28, 2023
2 parents 065cfaa + 298ea0e commit 46247c3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitIgnore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea/
.venv/
old/
old/
*.sh
3 changes: 2 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Validate data on PR

on:
workflow_call:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]

Expand Down Expand Up @@ -33,6 +33,7 @@ jobs:
python-version: '3.10'
# cache: poetry
- name: Install Poetry
if: steps.changes.outputs.data == 'true'
uses: snok/install-poetry@v1
- name: Install dependencies
if: steps.changes.outputs.data == 'true'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Upload data to triplestore

on:
workflow_call:
workflow_dispatch:
push:
branches:
- "main"
Expand Down Expand Up @@ -41,6 +41,7 @@ jobs:
python-version: '3.10'
# cache: poetry
- name: Install Poetry
if: steps.changes.outputs.data == 'true'
uses: snok/install-poetry@v1
- name: Install dependencies
if: steps.changes.outputs.data == 'true'
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This repository contains:

Also:

* `data/ubpublished/` contains data either previously published and removed but not deleted as it may be used again
* `data/unpublished/` contains data either previously published and removed but not deleted as it may be used again
Stored elsewhere are:

Expand Down
28 changes: 21 additions & 7 deletions scripts/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
TIMEOUT = 30.0

BACKGROUND_GRAPH_IRI = "https://background-data"
SCORES_GRAPH_IRI = "https://scores"

data_dir = Path(__file__).parent.parent / "data"

# if background files changed, clear & reupload to background named graph
def upload_background():
Expand All @@ -21,39 +24,50 @@ def upload_background():
sparql_update_query(f"DROP GRAPH <{BACKGROUND_GRAPH_IRI}>")

# upload everything in data/_background/
background_directory = Path(__file__).parent.parent / "data" / "_background"
background_directory = data_dir / "_background"
for f in background_directory.glob("*.ttl"):
upload_named_graph(f, BACKGROUND_GRAPH_IRI, False)

# prez profile
upload_named_graph(data_dir / "system" / "idn-prez-profile.ttl", BACKGROUND_GRAPH_IRI, False)

print("Upload complete")

# if catalog files changed, clear & reupload each catalog to its own named graph
def upload_catalogs():
"""Uploads all resource files from `data/catalogues/` and all catalogues from `data/system/`, both into their own named graphs."""
print("Uploading catalogues...")

sparql_update_query(f"DROP GRAPH <{SCORES_GRAPH_IRI}>")

# upload resources in data/catalogues/democat/
demo_directory = Path(__file__).parent.parent / "data" / "catalogues" / "democat"
demo_directory = data_dir / "catalogues" / "democat"
for f in demo_directory.glob("*.ttl"):
iri = find_named_graph(f, DCAT.Resource)
upload_named_graph(f, iri)
# upload scores
upload_named_graph(f"{demo_directory / 'scores'}/{f.stem}-fair.ttl", SCORES_GRAPH_IRI, False)
upload_named_graph(f"{demo_directory / 'scores'}/{f.stem}-care.ttl", SCORES_GRAPH_IRI, False)

# upload resources in data/catalogues/isucat/
isu_directory = Path(__file__).parent.parent / "data" / "catalogues" / "isucat"
isu_directory = data_dir / "catalogues" / "isucat"
for f in isu_directory.glob("*.ttl"):
iri = find_named_graph(f, DCAT.Resource)
upload_named_graph(f, iri)
# upload scores
upload_named_graph(f"{isu_directory / 'scores'}/{f.stem}-fair.ttl", SCORES_GRAPH_IRI, False)
upload_named_graph(f"{isu_directory / 'scores'}/{f.stem}-care.ttl", SCORES_GRAPH_IRI, False)

# upload catalog in data/system/catalog-democat.ttl
democat_path = Path(__file__).parent.parent / "data" / "system" / "catalog-democat.ttl"
democat_path = data_dir / "system" / "catalog-democat.ttl"
democat_iri = find_named_graph(democat_path, DCAT.Catalog)
upload_named_graph(democat_path, democat_iri)
# upload catalog in data/system/catalog-isu.ttl
isucat_path = Path(__file__).parent.parent / "data" / "system" / "catalog-isu.ttl"
isucat_path = data_dir / "system" / "catalog-isu.ttl"
isucat_iri = find_named_graph(isucat_path, DCAT.Catalog)
upload_named_graph(isucat_path, isucat_iri)
# upload catalog in data/system/catalog-system.ttl
systemcat_path = Path(__file__).parent.parent / "data" / "system" / "catalog-system.ttl"
systemcat_path = data_dir / "system" / "catalog-system.ttl"
systemcat_iri = find_named_graph(systemcat_path, DCAT.Catalog)
upload_named_graph(systemcat_path, systemcat_iri)

Expand Down Expand Up @@ -120,7 +134,7 @@ def upload_vocabs():
print("Uploading vocabularies...")

# upload vocabs in data/vocabularies/
vocab_directory = Path(__file__).parent.parent / "data" / "vocabularies"
vocab_directory = data_dir / "vocabularies"
for f in vocab_directory.glob("*.ttl"):
iri = find_named_graph(f, SKOS.ConceptScheme)
upload_named_graph(f, iri)
Expand Down

0 comments on commit 46247c3

Please sign in to comment.