-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/env variables #127
Draft
SvenLieber
wants to merge
3
commits into
RMLio:development
Choose a base branch
from
SvenLieber:feature/env-variables
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
51 changes: 51 additions & 0 deletions
51
test/env-variables/env-not-defined-warning-all/mapping.rml.ttl
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,51 @@ | ||
@prefix rr: <http://www.w3.org/ns/r2rml#>. | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#>. | ||
@prefix fno: <https://w3id.org/function/ontology#>. | ||
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#>. | ||
@prefix void: <http://rdfs.org/ns/void#>. | ||
@prefix dc: <http://purl.org/dc/terms/>. | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/>. | ||
@prefix rml: <http://semweb.mmlab.be/ns/rml#>. | ||
@prefix ql: <http://semweb.mmlab.be/ns/ql#>. | ||
@prefix : <http://mapping.example.com/>. | ||
@prefix ex: <http://example.org/ns#>. | ||
|
||
:rules_000 a void:Dataset; | ||
void:exampleResource :map_myMapping_000. | ||
:map_myMapping_000 rml:logicalSource :source_000. | ||
:source_000 a rml:LogicalSource; | ||
rml:source :database_000; | ||
rml:query "SELECT val1, val2 FROM tab". | ||
:database_000 a d2rq:Database; | ||
d2rq:jdbcDSN "//${DB_HOST}:${DB_PORT}/${DB}"; | ||
d2rq:jdbcDriver "org.postgresql.Driver"; | ||
d2rq:username "${DB_USER}"; | ||
d2rq:password "${DB_PASSWORD}". | ||
:source_000 rml:referenceFormulation ql:CSV. | ||
:map_myMapping_000 a rr:TriplesMap; | ||
rdfs:label "myMapping". | ||
:s_000 a rr:SubjectMap. | ||
:map_myMapping_000 rr:subjectMap :s_000. | ||
:s_000 rr:template "http://example.org/ns#entity_{val1}". | ||
:pom_000 a rr:PredicateObjectMap. | ||
:map_myMapping_000 rr:predicateObjectMap :pom_000. | ||
:pm_000 a rr:PredicateMap. | ||
:pom_000 rr:predicateMap :pm_000. | ||
:pm_000 rr:constant rdf:type. | ||
:pom_000 rr:objectMap :om_000. | ||
:om_000 a rr:ObjectMap; | ||
rr:constant "http://example.org/ns#Thing"; | ||
rr:termType rr:IRI. | ||
:pom_001 a rr:PredicateObjectMap. | ||
:map_myMapping_000 rr:predicateObjectMap :pom_001. | ||
:pm_001 a rr:PredicateMap. | ||
:pom_001 rr:predicateMap :pm_001. | ||
:pm_001 rr:constant ex:title. | ||
:pom_001 rr:objectMap :om_001. | ||
:om_001 a rr:ObjectMap; | ||
rml:reference "val2"; | ||
rr:termType rr:Literal; | ||
rml:languageMap :language_000. | ||
:language_000 rr:constant "en". |
22 changes: 22 additions & 0 deletions
22
test/env-variables/env-not-defined-warning-all/mapping.yml
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,22 @@ | ||
prefixes: | ||
ex: "http://example.org/ns#" | ||
|
||
variables: | ||
credentials: &credentials | ||
username: ${DB_USER} | ||
password: ${DB_PASSWORD} | ||
|
||
mappings: | ||
|
||
myMapping: | ||
sources: | ||
- access: //${DB_HOST}:${DB_PORT}/${DB} | ||
type: postgresql | ||
credentials: *credentials | ||
queryFormulation: sql2008 | ||
referenceFormulation: csv | ||
query: SELECT val1, val2 FROM tab | ||
s: ex:entity_$(val1) | ||
po: | ||
- [a, ex:Thing] | ||
- [ex:title, $(val2), en~lang] |
51 changes: 51 additions & 0 deletions
51
test/env-variables/env-not-defined-warning/mapping.rml.ttl
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,51 @@ | ||
@prefix rr: <http://www.w3.org/ns/r2rml#>. | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#>. | ||
@prefix fno: <https://w3id.org/function/ontology#>. | ||
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#>. | ||
@prefix void: <http://rdfs.org/ns/void#>. | ||
@prefix dc: <http://purl.org/dc/terms/>. | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/>. | ||
@prefix rml: <http://semweb.mmlab.be/ns/rml#>. | ||
@prefix ql: <http://semweb.mmlab.be/ns/ql#>. | ||
@prefix : <http://mapping.example.com/>. | ||
@prefix ex: <http://example.org/ns#>. | ||
|
||
:rules_000 a void:Dataset; | ||
void:exampleResource :map_myMapping_000. | ||
:map_myMapping_000 rml:logicalSource :source_000. | ||
:source_000 a rml:LogicalSource; | ||
rml:source :database_000; | ||
rml:query "SELECT val1, val2 FROM tab". | ||
:database_000 a d2rq:Database; | ||
d2rq:jdbcDSN "//myHost:myPort/${DB}"; | ||
d2rq:jdbcDriver "org.postgresql.Driver"; | ||
d2rq:username "${DB_USER}"; | ||
d2rq:password "${DB_PASSWORD}". | ||
:source_000 rml:referenceFormulation ql:CSV. | ||
:map_myMapping_000 a rr:TriplesMap; | ||
rdfs:label "myMapping". | ||
:s_000 a rr:SubjectMap. | ||
:map_myMapping_000 rr:subjectMap :s_000. | ||
:s_000 rr:template "http://example.org/ns#entity_{val1}". | ||
:pom_000 a rr:PredicateObjectMap. | ||
:map_myMapping_000 rr:predicateObjectMap :pom_000. | ||
:pm_000 a rr:PredicateMap. | ||
:pom_000 rr:predicateMap :pm_000. | ||
:pm_000 rr:constant rdf:type. | ||
:pom_000 rr:objectMap :om_000. | ||
:om_000 a rr:ObjectMap; | ||
rr:constant "http://example.org/ns#Thing"; | ||
rr:termType rr:IRI. | ||
:pom_001 a rr:PredicateObjectMap. | ||
:map_myMapping_000 rr:predicateObjectMap :pom_001. | ||
:pm_001 a rr:PredicateMap. | ||
:pom_001 rr:predicateMap :pm_001. | ||
:pm_001 rr:constant ex:title. | ||
:pom_001 rr:objectMap :om_001. | ||
:om_001 a rr:ObjectMap; | ||
rml:reference "val2"; | ||
rr:termType rr:Literal; | ||
rml:languageMap :language_000. | ||
:language_000 rr:constant "en". |
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,22 @@ | ||
prefixes: | ||
ex: "http://example.org/ns#" | ||
|
||
variables: | ||
credentials: &credentials | ||
username: ${DB_USER} | ||
password: ${DB_PASSWORD} | ||
|
||
mappings: | ||
|
||
myMapping: | ||
sources: | ||
- access: //${DB_HOST}:${DB_PORT}/${DB} | ||
type: postgresql | ||
credentials: *credentials | ||
queryFormulation: sql2008 | ||
referenceFormulation: csv | ||
query: SELECT val1, val2 FROM tab | ||
s: ex:entity_$(val1) | ||
po: | ||
- [a, ex:Thing] | ||
- [ex:title, $(val2), en~lang] |
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,51 @@ | ||
@prefix rr: <http://www.w3.org/ns/r2rml#>. | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#>. | ||
@prefix fno: <https://w3id.org/function/ontology#>. | ||
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#>. | ||
@prefix void: <http://rdfs.org/ns/void#>. | ||
@prefix dc: <http://purl.org/dc/terms/>. | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/>. | ||
@prefix rml: <http://semweb.mmlab.be/ns/rml#>. | ||
@prefix ql: <http://semweb.mmlab.be/ns/ql#>. | ||
@prefix : <http://mapping.example.com/>. | ||
@prefix ex: <http://example.org/ns#>. | ||
|
||
:rules_000 a void:Dataset; | ||
void:exampleResource :map_myMapping_000. | ||
:map_myMapping_000 rml:logicalSource :source_000. | ||
:source_000 a rml:LogicalSource; | ||
rml:source :database_000; | ||
rml:query "SELECT val1, val2 FROM tab". | ||
:database_000 a d2rq:Database; | ||
d2rq:jdbcDSN "//myHost:myPort/myDB"; | ||
d2rq:jdbcDriver "org.postgresql.Driver"; | ||
d2rq:username "dbUser"; | ||
d2rq:password "dbPassword". | ||
:source_000 rml:referenceFormulation ql:CSV. | ||
:map_myMapping_000 a rr:TriplesMap; | ||
rdfs:label "myMapping". | ||
:s_000 a rr:SubjectMap. | ||
:map_myMapping_000 rr:subjectMap :s_000. | ||
:s_000 rr:template "http://example.org/ns#entity_{val1}". | ||
:pom_000 a rr:PredicateObjectMap. | ||
:map_myMapping_000 rr:predicateObjectMap :pom_000. | ||
:pm_000 a rr:PredicateMap. | ||
:pom_000 rr:predicateMap :pm_000. | ||
:pm_000 rr:constant rdf:type. | ||
:pom_000 rr:objectMap :om_000. | ||
:om_000 a rr:ObjectMap; | ||
rr:constant "http://example.org/ns#Thing"; | ||
rr:termType rr:IRI. | ||
:pom_001 a rr:PredicateObjectMap. | ||
:map_myMapping_000 rr:predicateObjectMap :pom_001. | ||
:pm_001 a rr:PredicateMap. | ||
:pom_001 rr:predicateMap :pm_001. | ||
:pm_001 rr:constant ex:title. | ||
:pom_001 rr:objectMap :om_001. | ||
:om_001 a rr:ObjectMap; | ||
rml:reference "val2"; | ||
rr:termType rr:Literal; | ||
rml:languageMap :language_000. | ||
:language_000 rr:constant "en". |
Oops, something went wrong.
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.
Why can't we use normal brackets as well here? And check all variables if they are defined in the
.env
?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.
So you mean
$(DB_PASSWORD)
?This would clash with YARRRML templates: https://rml.io/yarrrml/spec/#template
Thus if you would (for some reason) specify
value=myValue
in your.env
then also yarrrml templates$(value)
would be replaced.Similarly, if you would define
VALUE=myValue
in.env
then a potential yarrrml template$(VALUE)
would be replaced.Such a clash with YARRRML templates is in my opinion not intended, because they reflect e.g. column names in a source.
Furthermore, curly braces (or no braces) are the common way to represent (environment) variables in UNIX, regular brackets are used for sub-shells: https://dev.to/rpalo/bash-brackets-quick-reference-4eh6
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.
Or do the same as with the external references? Adding a
_
before the variable name? so you would have then$(_DB_PASSWORD)
? So external references can come from both the CLI and.env
, which makes sense.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.
This would technically work but would be a convention which has to be used just because of YARRRML and therefore would harm reusability/interoperability in cases where YARRRML is not the only component.
There might be other components using
.env
variables, for example a script which creates an SSH tunnel to a remote DB host behind a firewall, some UI component or any other application doing something.IMHO YARRRML should integrate into an existing setup as easy as possible. A setup in which certain environment variables are already in place and are used by other systems. As a user I would not want to change my whole application the moment I want to integrate YARRRML mappings. This could be a potential pitfall preventing people from using YARRRML.
As I see it, reducing the expressibility of environment variables (only with prefixed underscore) just to combine it with external references (which already can be provided via parameter) would limit this feature.
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.
You only have to change your YARRRML files, nothing else. The variables names remain the same. You only add the
_
in the YARRRML template.