-
Notifications
You must be signed in to change notification settings - Fork 31
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
refactoring provonerdf and uncomment test_experiment #105
Open
sanuann
wants to merge
5
commits into
incf-nidash:master
Choose a base branch
from
sanuann:provone
base: master
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.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
acf1425
refactoring provonerdf and uncomment test_experiment
sanuann def5e2d
remove commented lines from provone, comment 2 tests in test_provone …
sanuann 5863245
Merge pull request #2 from incf-nidash/master
sanuann a1ff8c3
Merge pull request #3 from sanuann/master
sanuann 944e05d
pull latests from master and refactor test_provone
sanuann 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
from prov.model import ProvEntity, ProvAgent, ProvDocument, ProvAttribution, \ | ||
PROV_REC_CLS, ProvActivity, _ensure_datetime, ProvAssociation, \ | ||
ProvCommunication, ProvDerivation, ProvRelation, ProvGeneration, ProvUsage, \ | ||
ProvMembership | ||
ProvMembership, ProvRecord | ||
from .Constants import PROVONE_N_MAP, PROVONE_PROCESS, PROVONE_INPUTPORT, \ | ||
PROVONE_OUTPUTPORT, PROVONE_DATA, PROVONE_DATALINK, PROVONE_SEQCTRLLINK, \ | ||
PROVONE_USER, PROVONE_PROCESSEXEC, PROVONE_ATTR_PROCESS, PROVONE_ATTR_USER, \ | ||
|
@@ -43,11 +43,22 @@ | |
|
||
logger = logging.getLogger(__name__) | ||
|
||
# add ProvOne Notation mapping to Prov_N_MAP dict | ||
#PROV_N_MAP.update(PROVONE_N_MAP) | ||
# update ProvOne Notation mapping with PROV_N_MAP | ||
PROVONE_N_MAP.update(PROV_N_MAP) | ||
|
||
|
||
class ProvOneRecord(ProvRecord): | ||
"""Base class for PROVONE records.""" | ||
|
||
def copy(self): | ||
""" | ||
Return an exact copy of this record. | ||
""" | ||
return PROVONE_REC_CLS[self.get_type()]( | ||
self._bundle, self.identifier, self.attributes | ||
) | ||
|
||
|
||
class ProvPlan(ProvEntity): | ||
""" | ||
ProvONE Plan element | ||
|
@@ -144,15 +155,15 @@ class Generation(ProvGeneration): | |
|
||
FORMAL_ATTRIBUTES = (PROVONE_ATTR_DATA, PROVONE_ATTR_PROCESSEXEC, PROV_ATTR_TIME) | ||
|
||
#_prov_type = PROV_GENERATION | ||
_prov_type = PROV_GENERATION | ||
|
||
|
||
class Usage(ProvUsage): | ||
"""Provenance Usage relationship.""" | ||
|
||
FORMAL_ATTRIBUTES = (PROVONE_ATTR_PROCESSEXEC, PROVONE_ATTR_DATA, PROV_ATTR_TIME) | ||
|
||
#_prov_type = PROV_USAGE | ||
_prov_type = PROV_USAGE | ||
|
||
|
||
class Partnership(ProvRelation): | ||
|
@@ -268,16 +279,17 @@ class Workflow(Process, ): | |
|
||
|
||
# Class mappings from PROVONE record type | ||
PROV_REC_CLS.update({ | ||
PROVONE_REC_CLS = { | ||
PROVONE_PROCESS: Process, | ||
PROVONE_PROCESSEXEC: ProcessExec, | ||
PROVONE_DATA: Data, | ||
PROV_ATTRIBUTION: Attribution, | ||
PROV_ASSOCIATION: Association, | ||
PROV_COMMUNICATION: Communication, | ||
PROV_DERIVATION: Derivation, | ||
PROV_GENERATION: Generation, | ||
# PROV_ATTRIBUTION: Attribution, | ||
# PROV_ASSOCIATION: Association, | ||
# PROV_COMMUNICATION: Communication, | ||
# PROV_DERIVATION: Derivation, | ||
# PROV_GENERATION: Generation, | ||
PROV_USAGE: Usage, | ||
# PROV_MEMBERSHIP: Membership, | ||
PROVONE_INPUTPORT: InputPort, | ||
PROVONE_HASINPORT: HasInput, | ||
PROVONE_OUTPUTPORT: OutputPort, | ||
|
@@ -295,9 +307,41 @@ class Workflow(Process, ): | |
PROVONE_HASDEFAULTPARAM: Parameterization, | ||
PROVONE_USER: User, | ||
PROVONE_ISPARTOF: Partnership, | ||
PROV_MEMBERSHIP: Membership, | ||
|
||
}) | ||
} | ||
|
||
PROVONE_REC_CLS.update(PROV_REC_CLS) | ||
|
||
# PROV_REC_CLS.update({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented lines |
||
# PROVONE_PROCESS: Process, | ||
# PROVONE_PROCESSEXEC: ProcessExec, | ||
# PROVONE_DATA: Data, | ||
# PROV_ATTRIBUTION: Attribution, | ||
# PROV_ASSOCIATION: Association, | ||
# PROV_COMMUNICATION: Communication, | ||
# PROV_DERIVATION: Derivation, | ||
# PROV_GENERATION: Generation, | ||
# PROV_USAGE: Usage, | ||
# PROVONE_INPUTPORT: InputPort, | ||
# PROVONE_HASINPORT: HasInput, | ||
# PROVONE_OUTPUTPORT: OutputPort, | ||
# PROVONE_HASOUTPORT: HasOutput, | ||
# PROVONE_HASSUBPROCESS: HasSubProcess, | ||
# PROVONE_DATALINK: DataLink, | ||
# PROVONE_INPORTTODL: InToDL, | ||
# PROVONE_SEQCTRLLINK: SeqCtrlLink, | ||
# PROVONE_CLTODESTP: CLtoDestP, | ||
# PROVONE_SOURCEPTOCL: SourcePtoCL, | ||
# PROVONE_OUTPORTTODL: OutToDL, | ||
# PROVONE_DLTOOUTPORT: DLtoOutPort, | ||
# PROVONE_DLTOINPORT: DLtoInPort, | ||
# PROVONE_DATAONLINK: DataLinkage, | ||
# PROVONE_HASDEFAULTPARAM: Parameterization, | ||
# PROVONE_USER: User, | ||
# PROVONE_ISPARTOF: Partnership, | ||
# PROV_MEMBERSHIP: Membership, | ||
# | ||
# }) | ||
|
||
|
||
class ProvONEDocument(ProvDocument): | ||
|
@@ -848,6 +892,41 @@ def membership(self, collection, data): | |
} | ||
) | ||
|
||
# same method as in prov/model.py with just the modification of PROVONE | ||
# constants. Need to re-architect prov and then make necessary changes in | ||
# provone. | ||
def new_record(self, record_type, identifier, attributes=None, | ||
other_attributes=None): | ||
""" | ||
Creates a new record. | ||
|
||
:param record_type: Type of record (one of :py:const:`PROVONE_REC_CLS`). | ||
:param identifier: Identifier for new record. | ||
:param attributes: Attributes as a dictionary or list of tuples to be added | ||
to the record optionally (default: None). | ||
:param other_attributes: Optional other attributes as a dictionary or list | ||
of tuples to be added to the record optionally (default: None). | ||
""" | ||
attr_list = [] | ||
if attributes: | ||
if isinstance(attributes, dict): | ||
attr_list.extend( | ||
(attr, value) for attr, value in attributes.items() | ||
) | ||
else: | ||
# expecting a list of attributes here | ||
attr_list.extend(attributes) | ||
if other_attributes: | ||
attr_list.extend( | ||
other_attributes.items() if isinstance(other_attributes, dict) | ||
else other_attributes | ||
) | ||
new_record = PROVONE_REC_CLS[record_type]( | ||
self, self.valid_qualified_name(identifier), attr_list | ||
) | ||
self._add_record(new_record) | ||
return new_record | ||
|
||
# Aliases | ||
wasAttributedTo = attribution | ||
wasAssociatedWith = association | ||
|
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
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.
since git tracks code, better to remove than comment.