-
Notifications
You must be signed in to change notification settings - Fork 22
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
WIP: add changes to make quitstore working with eccenca DataPlatform #240
base: master
Are you sure you want to change the base?
Changes from 2 commits
4cbea54
ec109cd
f07b7a2
ed77fb9
0db4360
c9c3234
a83d34f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,7 @@ def __initstoreconfig(self, namespace, upstream, targetdir, configfile): | |
return | ||
|
||
def hasFeature(self, flags): | ||
return flags == (self.features & flags) | ||
return flags == (self.features and flags) | ||
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. This has to be an 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. Yes, this is only related to changes for FEATURES |
||
|
||
def getBindings(self): | ||
q = """SELECT DISTINCT ?prefix ?namespace WHERE {{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,14 +415,41 @@ def getFileReferenceAndContext(self, blob, commit): | |
return self._blobs.get(blob) | ||
|
||
def applyQueryOnCommit(self, parsedQuery, parent_commit_ref, target_ref, query=None, | ||
default_graph=[], named_graph=[]): | ||
default_graph=[], named_graph=[], queryType=None, comment=None): | ||
"""Apply an update query on the graph and the git repository.""" | ||
graph, commitid = self.instance(parent_commit_ref) | ||
resultingChanges, exception = graph.update(parsedQuery) | ||
if exception: | ||
# TODO need to revert or invalidate the graph at this point. | ||
pass | ||
oid = self.commit(graph, resultingChanges, 'New Commit from QuitStore', parent_commit_ref, | ||
|
||
graphuri = None | ||
|
||
if comment is not None: | ||
queryType = comment | ||
elif len(resultingChanges) > 1: | ||
queryType = 'Edit resource in' | ||
for entry in resultingChanges: | ||
if "delta" in entry: | ||
for x in entry["delta"]: | ||
graphuri = str(x) | ||
if queryType == 'Modify': | ||
ls = entry["delta"][x] | ||
if len(ls) == 1 and "removals" in ls[0]: | ||
queryType = 'Remove resource in' | ||
elif len(ls) == 1 and "additions" in ls[0]: | ||
queryType = 'Add resource in' | ||
|
||
if queryType is not None and graphuri is not None: | ||
if queryType == 'InsertData' or queryType == 'Load': | ||
message = 'Insert data into Graph <' + graphuri + '>' | ||
elif queryType == 'DeleteData' or queryType == 'DeleteWhere': | ||
message = 'Delete data from Graph <' + graphuri + '>' | ||
else: | ||
message = queryType + ' Graph <' + graphuri + '>' | ||
else: | ||
message = 'New Commit from QuitStore' | ||
oid = self.commit(graph, resultingChanges, message, parent_commit_ref, | ||
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. Yes, 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. See #237 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. Thanks for the tip! Yes I understand, just want to show the possibility during demonstration =) |
||
target_ref, query=query, default_graph=default_graph, | ||
named_graph=named_graph) | ||
if exception: | ||
|
@@ -474,7 +501,7 @@ def commit(self, graph, delta, message, parent_commit_ref, target_ref, query=Non | |
graphconfig = self._graphconfigs.get(parent_commit_id) | ||
known_files = graphconfig.getfiles().keys() | ||
|
||
blobs_new = self._applyKnownGraphs(delta, blobs, parent_commit, index) | ||
blobs_new = self._applyKnownGraphs(delta, blobs, parent_commit, index, graphconfig) | ||
new_contexts = self._applyUnknownGraphs(delta, known_files) | ||
new_config = copy(graphconfig) | ||
|
||
|
@@ -536,25 +563,39 @@ def _build_message(self, message, query, result, default_graph, named_graph, **k | |
out.append('{}: "{}"'.format(k, v.replace('"', "\\\""))) | ||
return "\n".join(out) | ||
|
||
def _applyKnownGraphs(self, delta, blobs, parent_commit, index): | ||
def _applyKnownGraphs(self, delta, blobs, parent_commit, index, graphconfig): | ||
blobs_new = set() | ||
for blob in blobs: | ||
(fileName, oid) = blob | ||
type = None | ||
|
||
try: | ||
file_reference, context = self.getFileReferenceAndContext(blob, parent_commit) | ||
for entry in delta: | ||
|
||
changeset = entry['delta'].get(context.identifier, None) | ||
|
||
if changeset: | ||
applyChangeset(file_reference, changeset, context.identifier) | ||
del(entry['delta'][context.identifier]) | ||
|
||
index.add(file_reference.path, file_reference.content) | ||
type = entry['type'] | ||
if type == 'DROP': | ||
index.remove(file_reference.path) | ||
index.remove(file_reference.path + '.graph') | ||
graphconfig.removegraph(context.identifier) | ||
del (entry['delta'][context.identifier]) | ||
else: | ||
applyChangeset(file_reference, changeset, context.identifier) | ||
del (entry['delta'][context.identifier]) | ||
|
||
self._blobs.remove(blob) | ||
blob = fileName, index.stash[file_reference.path][0] | ||
self._blobs.set(blob, (file_reference, context)) | ||
blobs_new.add(blob) | ||
|
||
if type == 'DROP': | ||
pass | ||
else: | ||
index.add(file_reference.path, file_reference.content) | ||
blob = fileName, index.stash[file_reference.path][0] | ||
self._blobs.set(blob, (file_reference, context)) | ||
blobs_new.add(blob) | ||
|
||
except KeyError: | ||
pass | ||
return blobs_new | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -658,7 +658,8 @@ def commit(self, message, author_name, author_email, **kwargs): | |
commiter = pygit2.Signature(commiter_name, commiter_email) | ||
|
||
# Sort index items | ||
items = sorted(self.stash.items(), key=lambda x: (x[1][0], x[0])) | ||
#items = sorted(self.stash.items(), key=lambda x: (x[1][0], x[0])) | ||
items = list(self.stash.items()) | ||
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. @huwenxin Is it unimportant to sort the index? Could we maybe even just use 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. During testing I found that sometimes the self.stash.items() was None so that sorted would result in error. It's also possible to use self.stash.items() instead of items below. By the way, I will list the changes/features I've made and send you later, as well as a newer version of code. |
||
|
||
# Create tree | ||
tree = IndexTree(self) | ||
|
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.
The features should be set using the command line arguments instead of environment variables, if this is possible.
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.
Is it possible to set the environment variables using Docker? I only found the git-way to set this environment variable.
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.
@seebi could you please try if you can use the
--feature
command line option instead of the environment variables in the orchestration (https://github.com/AKSW/QuitStore#command-line-options)?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.
yes, i can overwrite it in our compose file