Skip to content

Docker image fix + bump deps #63

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

Merged
merged 2 commits into from
Apr 12, 2019
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
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ COPY . /splitgraph
RUN $HOME/.poetry/bin/poetry config settings.virtualenvs.create false
RUN cd /splitgraph && $HOME/.poetry/bin/poetry install --no-dev

# The pip-wheel-metadata is supposed to be temporary. For downstream image builds, Poetry tries to reinstall Splitgraph
# from /splitgraph again and fails with
#
# FileExistsError: [Errno 17] File exists: '/splitgraph/pip-wheel-metadata
# /splitgraph-0.0.0.dist-info'
# See https://github.com/pypa/pip/issues/6213
RUN rm /splitgraph/pip-wheel-metadata -rf

CMD sgr
36 changes: 18 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions splitgraph/core/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ def set_head(repository, image):
set_tag(repository, image, 'HEAD')


def manage_audit_triggers(engine):
def manage_audit_triggers(engine, object_engine=None):
"""Does bookkeeping on audit triggers / audit table:

* Detect tables that are being audited that don't need to be any more
(e.g. they've been unmounted)
* Drop audit triggers for those and delete all audit info for them
* Set up audit triggers for new tables

:param engine: Metadata engine with information about images and their checkout state
:param object_engine: Object engine where the checked-out table and the audit triggers are located.
"""

object_engine = object_engine or engine

from splitgraph.core.engine import get_current_repositories
repos_tables = [(r.to_schema(), t) for r, head in get_current_repositories(engine) if head is not None
for t in set(engine.get_all_tables(r.to_schema())) & set(head.get_tables())]
Expand All @@ -48,10 +53,10 @@ def manage_audit_triggers(engine):
to_track = [t for t in repos_tables if t not in tracked_tables]

if to_untrack:
engine.untrack_tables(to_untrack)
object_engine.untrack_tables(to_untrack)

if to_track:
engine.track_tables(to_track)
object_engine.track_tables(to_track)


def manage_audit(func):
Expand All @@ -69,11 +74,11 @@ def wrapped(self, *args, **kwargs):
repository = self
try:
ensure_metadata_schema(repository.engine)
manage_audit_triggers(repository.engine)
manage_audit_triggers(repository.engine, repository.object_engine)
return func(self, *args, **kwargs)
finally:
self.engine.commit()
manage_audit_triggers(repository.engine)
manage_audit_triggers(repository.engine, repository.object_engine)

return wrapped

Expand Down
3 changes: 2 additions & 1 deletion splitgraph/core/metadata_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def get_object_meta(self, objects):
return {}

metadata = self.metadata_engine.run_sql(select("get_object_meta", ','.join(OBJECT_COLS),
schema=SPLITGRAPH_API_SCHEMA, table_args="(%s)"), (objects,))
schema=SPLITGRAPH_API_SCHEMA, table_args="(%s)"),
(list(objects),))
result = [Object(*m) for m in metadata]
return {o.object_id: o for o in result}
4 changes: 2 additions & 2 deletions splitgraph/core/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def commit(self, image_hash=None, comment=None, snap_only=False, chunk_size=1000
logging.info("Committing %s...", self.to_schema())

self.object_engine.commit()
manage_audit_triggers(self.object_engine)
manage_audit_triggers(self.engine, self.object_engine)

# HEAD can be None (if this is the first commit in this repository)
head = self.head
Expand All @@ -410,7 +410,7 @@ def commit(self, image_hash=None, comment=None, snap_only=False, chunk_size=1000
self._commit(head, image_hash, snap_only=snap_only, chunk_size=chunk_size, split_changeset=split_changeset)

set_head(self, image_hash)
manage_audit_triggers(self.engine)
manage_audit_triggers(self.engine, self.object_engine)
self.object_engine.commit()
self.engine.commit()
return self.images.by_hash(image_hash)
Expand Down