Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
pymdown-extensions

- name: Install library
run: pip install -e ./csvw-safe-library
run: pip install -e ./csvw-eo-library

- name: Sync images
run: |
mkdir -p docs/images
cp -r images/* docs/images/
cp -r csvw-safe-library/images/* docs/images/
cp -r csvw-eo-library/images/* docs/images/

- name: Build docs
run: mkdocs build
Expand All @@ -46,5 +46,5 @@ jobs:
with:
source-directory: site/
destination-github-username: dscc-admin-ch
destination-repository-name: csvw-safe-docs
destination-repository-name: csvw-eo-docs
target-branch: main
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

defaults:
run:
working-directory: csvw-safe-library
working-directory: csvw-eo-library

steps:
- name: Checkout repo
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd csvw-safe-library
cd csvw-eo-library
pip install -e .[dev]

- name: Run tests with coverage
run: |
cd csvw-safe-library
cd csvw-eo-library
coverage run -m pytest . -vv
coverage xml

- name: Coverage comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERAGE_PATH: csvw-safe-library/
COVERAGE_PATH: csvw-eo-library/
MINIMUM_GREEN: 90
MINIMUM_ORANGE: 80
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ __pycache__/*
*pyd
images/*ipynb*
*/build/*
*/csvw_safe.egg-info/*
*/csvw_eo.egg-info/*
*.ipynb_checkpoints/*
.ipynb_checkpoints/
*coverage
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CSVW-SAFE
# CSVW-EO

CSVW-SAFE extends the W3C CSV on the Web (CSVW) standard with
CSVW-EO extends the W3C CSV on the Web (CSVW) standard with
privacy-safe metadata for:

- Differential Privacy contribution modeling
Expand All @@ -10,16 +10,16 @@ privacy-safe metadata for:
- Validation workflows

Documentation:
https://dscc-admin-ch.github.io/csvw-safe-docs/
https://dscc-admin-ch.github.io/csvw-eo-docs/

---

## Why CSVW-SAFE?
## Why CSVW-EO?

Many datasets cannot be shared directly due to privacy or governance
constraints.

CSVW-SAFE allows publishing safe assumptions about datasets without
CSVW-EO allows publishing safe assumptions about datasets without
sharing the underlying sensitive data.

Examples include:
Expand All @@ -30,32 +30,32 @@ Examples include:
- contribution bounds for DP
- logical dependencies

![Overview](images/csvw-safe_structure.png)
![Overview](images/csvw-eo_structure.png)

---

## Repository Structure

| Component | Description |
|---|---|
| `csvw-safe-library/` | Python library |
| `csvw-eo-library/` | Python library |
| `docs/` | MkDocs documentation |
| `csvw-safe-vocab.ttl` | RDF vocabulary |
| `csvw-safe-constraints.ttl` | SHACL validation rules |
| `csvw-eo-vocab.ttl` | RDF vocabulary |
| `csvw-eo-constraints.ttl` | SHACL validation rules |

---

## Installation

```bash
pip install csvw-safe
pip install csvw-eo
```

## Quick Example

```bash
from csvw_safe.make_metadata_from_data import make_metadata_from_data
from csvw_safe.make_dummy_from_metadata import make_dummy_from_metadata
from csvw_eo.make_metadata_from_data import make_metadata_from_data
from csvw_eo.make_dummy_from_metadata import make_dummy_from_metadata

metadata = make_metadata_from_data(
df,
Expand All @@ -68,6 +68,6 @@ dummy_df = make_dummy_from_metadata(metadata)

| Section | Link |
| -------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Vocabulary | [https://dscc-admin-ch.github.io/csvw-safe-docs/vocabulary/overview/](https://dscc-admin-ch.github.io/csvw-safe-docs/vocabulary/overview/) |
| Python Library | [https://dscc-admin-ch.github.io/csvw-safe-docs/library/overview/](https://dscc-admin-ch.github.io/csvw-safe-docs/library/overview/) |
| API Reference | [https://dscc-admin-ch.github.io/csvw-safe-docs/api/](https://dscc-admin-ch.github.io/csvw-safe-docs/api/) |
| Vocabulary | [https://dscc-admin-ch.github.io/csvw-eo-docs/vocabulary/overview/](https://dscc-admin-ch.github.io/csvw-eo-docs/vocabulary/overview/) |
| Python Library | [https://dscc-admin-ch.github.io/csvw-eo-docs/library/overview/](https://dscc-admin-ch.github.io/csvw-eo-docs/library/overview/) |
| API Reference | [https://dscc-admin-ch.github.io/csvw-eo-docs/api/](https://dscc-admin-ch.github.io/csvw-eo-docs/api/) |
24 changes: 12 additions & 12 deletions csvw-safe-constraints.md → csvw-eo-constraints.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CSVW-SAFE Constraints
# CSVW-EO Constraints

CSVW-SAFE enforces constraints to ensure:
CSVW-EO enforces constraints to ensure:

- Structural consistency of the admissible dataset universe
- Sound worst-case sensitivity computation
Expand All @@ -15,9 +15,9 @@ Applied to `csvw:Table`:
The following properties are required if the dataset is intended for DP calibration:
| Property | Constraint |
| ----------------------------------- | ----------------------------------------- |
| `csvw-safe:public.privacyUnit` | MUST reference an existing column |
| `csvw-safe:bounds.maxLength` | MUST be declared |
| `csvw-safe:bounds.maxContributions` | MUST be declared and ≤ `bounds.maxLength` |
| `csvw-eo:public.privacyUnit` | MUST reference an existing column |
| `csvw-eo:bounds.maxLength` | MUST be declared |
| `csvw-eo:bounds.maxContributions` | MUST be declared and ≤ `bounds.maxLength` |

If there is no groupy, then these fields are compulsory at the table level.
If there is a groupby, then these fields are compulsory at the partition level.
Expand All @@ -27,8 +27,8 @@ If there is a groupby, then these fields are compulsory at the partition level.

| Property | Constraint |
| ----------------------------------- | ------------------------------------------------------------------------ |
| `csvw-safe:public.length` | If declared, MUST be ≤ `bounds.maxLength` and invariant across neighbors |
| `csvw-safe:bounds.maxNumPartitions` | If declared at table level, MUST be ≥ 1 |
| `csvw-eo:public.length` | If declared, MUST be ≤ `bounds.maxLength` and invariant across neighbors |
| `csvw-eo:bounds.maxNumPartitions` | If declared at table level, MUST be ≥ 1 |

### 4.1.3 Global consistency rules

Expand Down Expand Up @@ -64,7 +64,7 @@ If column-level bounds are omitted, table-level bounds apply.

## 4.3 Multi-Column GroupingKey Constraints

Applied to `csvw-safe:GroupingKey`.
Applied to `csvw-eo:GroupingKey`.

### 4.3.1 Structural consistency

Expand Down Expand Up @@ -98,7 +98,7 @@ For a grouping key G composed of columns $C_1, C_2, ..., C_n$:

## 4.4 Partition-Level Constraints

Applied to `csvw-safe:Partition`.
Applied to `csvw-eo:Partition`.

A Partition represents exactly one output coordinate.

Expand Down Expand Up @@ -128,7 +128,7 @@ Implicit rule:

## 4.5 Contribution Object Constraints (Multiple Privacy Units)

Applied to `csvw-safe:Contribution`.
Applied to `csvw-eo:Contribution`.

### 4.5.1 Structural rules
| Rule | Enforcement |
Expand Down Expand Up @@ -187,5 +187,5 @@ If any required property is missing: DP bounds are undefined.

## 4.9 SHACL Enforcement

Some constraints are enforcet in [`csvw-safe-constraints.ttl`](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/csvw-safe-constraints.ttl).
Other more detailed constraints are in [`validate_metadata.py`](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/csvw-safe/validate_metadata.py) and [`validate_metadata_shacl.py`](https://github.com/dscc-admin-ch/csvw-safe/blob/main/csvw-safe-library/csvw-safe/validate_metadata_shacl.py) can run the shacl constraints.
Some constraints are enforcet in [`csvw-eo-constraints.ttl`](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/csvw-eo-constraints.ttl).
Other more detailed constraints are in [`validate_metadata.py`](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/csvw-eo/validate_metadata.py) and [`validate_metadata_shacl.py`](https://github.com/dscc-admin-ch/csvw-eo/blob/main/csvw-eo-library/csvw-eo/validate_metadata_shacl.py) can run the shacl constraints.
2 changes: 1 addition & 1 deletion csvw-safe-constraints.ttl → csvw-eo-constraints.ttl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix csvw: <http://www.w3.org/ns/csvw#> .
@prefix cs: <http://example.org/csvw-safe#> .
@prefix cs: <http://example.org/csvw-eo#> .

############################################
# Table
Expand Down
54 changes: 27 additions & 27 deletions csvw-safe-context.jsonld → csvw-eo-context.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,65 @@
"@context": {

"csvw": "http://www.w3.org/ns/csvw#",
"csvw-safe": "https://w3id.org/csvw-safe#",
"csvw-eo": "https://w3id.org/csvw-eo#",
"xsd": "http://www.w3.org/2001/XMLSchema#",

"@version": 1.1,

"Table": "csvw:Table",
"Column": "csvw:Column",

"GroupingKey": "csvw-safe:GroupingKey",
"Partition": "csvw-safe:Partition",
"Predicate": "csvw-safe:Predicate",
"Contribution": "csvw-safe:Contribution",
"GroupingKey": "csvw-eo:GroupingKey",
"Partition": "csvw-eo:Partition",
"Predicate": "csvw-eo:Predicate",
"Contribution": "csvw-eo:Contribution",

"columns": {
"@id": "csvw-safe:columns",
"@id": "csvw-eo:columns",
"@type": "@id",
"@container": "@set"
},

"predicate": {
"@id": "csvw-safe:predicate",
"@id": "csvw-eo:predicate",
"@type": "@id"
},

"components": {
"@id": "csvw-safe:components",
"@id": "csvw-eo:components",
"@type": "@id",
"@container": "@index"
},

"partitionValue": "csvw-safe:partitionValue",
"partitionValue": "csvw-eo:partitionValue",
"lowerBound": {
"@id": "csvw-safe:lowerBound",
"@id": "csvw-eo:lowerBound",
"@type": "xsd:decimal"
},
"upperBound": {
"@id": "csvw-safe:upperBound",
"@id": "csvw-eo:upperBound",
"@type": "xsd:decimal"
},

"privacyModel": "csvw-safe:privacyModel",
"privacyModel": "csvw-eo:privacyModel",

"public": {
"@context": {
"privacyUnit": {
"@id": "csvw-safe:public.privacyUnit",
"@id": "csvw-eo:public.privacyUnit",
"@type": "@id"
},
"length": {
"@id": "csvw-safe:public.length",
"@id": "csvw-eo:public.length",
"@type": "xsd:integer"
},
"partitions": {
"@id": "csvw-safe:public.partitions",
"@id": "csvw-eo:public.partitions",
"@type": "@id",
"@container": "@set"
},
"exhaustivePartitions": {
"@id": "csvw-safe:public.exhaustivePartitions",
"@id": "csvw-eo:public.exhaustivePartitions",
"@type": "xsd:boolean"
}
}
Expand All @@ -69,41 +69,41 @@
"bounds": {
"@context": {
"maxContributions": {
"@id": "csvw-safe:bounds.maxContributions",
"@id": "csvw-eo:bounds.maxContributions",
"@type": "xsd:integer"
},
"maxGroupsPerUnit": {
"@id": "csvw-safe:bounds.maxGroupsPerUnit",
"@id": "csvw-eo:bounds.maxGroupsPerUnit",
"@type": "xsd:integer"
},
"maxLength": {
"@id": "csvw-safe:bounds.maxLength",
"@id": "csvw-eo:bounds.maxLength",
"@type": "xsd:integer"
},
"maxNumPartitions": {
"@id": "csvw-safe:bounds.maxNumPartitions",
"@id": "csvw-eo:bounds.maxNumPartitions",
"@type": "xsd:integer"
}
}
},

"contribution": {
"@id": "csvw-safe:contribution",
"@id": "csvw-eo:contribution",
"@type": "@id"
},

"contrib": {
"@context": {
"privacyUnit": {
"@id": "csvw-safe:contribution.privacyUnit",
"@id": "csvw-eo:contribution.privacyUnit",
"@type": "@id"
},
"maxContributions": {
"@id": "csvw-safe:contribution.maxContributions",
"@id": "csvw-eo:contribution.maxContributions",
"@type": "xsd:integer"
},
"maxGroupsPerUnit": {
"@id": "csvw-safe:contribution.maxGroupsPerUnit",
"@id": "csvw-eo:contribution.maxGroupsPerUnit",
"@type": "xsd:integer"
}
}
Expand All @@ -112,14 +112,14 @@
"synth": {
"@context": {
"nullableProportion": {
"@id": "csvw-safe:synth.nullableProportion",
"@id": "csvw-eo:synth.nullableProportion",
"@type": "xsd:decimal"
},
"dependency": {
"@id": "csvw-safe:synth.dependency",
"@id": "csvw-eo:synth.dependency",
"@type": "@id"
},
"dependencyType": "csvw-safe:synth.dependencyType"
"dependencyType": "csvw-eo:synth.dependencyType"
}
}
}
Expand Down
File renamed without changes.
Loading
Loading