Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #158 from pypeclub/feature/loader_with_aggregation…
Browse files Browse the repository at this point in the history
…_loading_state

Feature/loader with aggregation loading state
  • Loading branch information
mkolar authored Jul 17, 2020
2 parents 9e92a24 + 5dd433b commit b3452ed
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 155 deletions.
6 changes: 6 additions & 0 deletions avalon/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,12 @@ def distinct(*args, **kwargs):
*args, **kwargs)


@auto_reconnect
def aggregate(*args, **kwargs):
return self._database[Session["AVALON_PROJECT"]].aggregate(
*args, **kwargs)


@auto_reconnect
def drop(*args, **kwargs):
return self._database[Session["AVALON_PROJECT"]].drop(
Expand Down
7 changes: 7 additions & 0 deletions avalon/tools/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,10 @@ def project_use_silo(project_doc):
if "{silo}" in template:
return True
return False


def create_qthread(func, *args, **kwargs):
class Thread(QtCore.QThread):
def run(self):
func(*args, **kwargs)
return Thread()
5 changes: 5 additions & 0 deletions avalon/tools/libraryloader/io_nonsingleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ def distinct(self, *args, **kwargs):
return self._database[self.Session["AVALON_PROJECT"]].distinct(
*args, **kwargs)

@auto_reconnect
def aggregate(self, *args, **kwargs):
return self._database[self.Session["AVALON_PROJECT"]].aggregate(
*args, **kwargs)

@auto_reconnect
def drop(self, *args, **kwargs):
return self._database[self.Session["AVALON_PROJECT"]].drop(
Expand Down
35 changes: 20 additions & 15 deletions avalon/tools/loader/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,32 @@ def _assetschanged(self):

assets_widget = self.data["model"]["assets"]
subsets_widget = self.data["model"]["subsets"]
subsets_model = subsets_widget.model

subsets_widget.model.clear()
subsets_model.clear()
self.clear_assets_underlines()

# filter None docs they are silo
asset_docs = assets_widget.get_selected_assets()
if len(asset_docs) == 0:
return

asset_ids = [asset_doc["_id"] for asset_doc in asset_docs]
subsets_widget.model.set_assets(asset_ids)
# Start loading
subsets_widget.set_loading_state(
loading=bool(asset_ids),
empty=True
)

def on_refreshed(has_item):
empty = not has_item
subsets_widget.set_loading_state(loading=False, empty=empty)
subsets_model.refreshed.disconnect()
self.echo("Duration: %.3fs" % (time.time() - t1))

subsets_model.refreshed.connect(on_refreshed)

subsets_model.set_assets(asset_ids)
subsets_widget.view.setColumnHidden(
subsets_widget.model.Columns.index("asset"),
subsets_model.Columns.index("asset"),
len(asset_ids) < 2
)

Expand All @@ -212,8 +225,6 @@ def _assetschanged(self):

self.data["state"]["assetIds"] = asset_ids

self.echo("Duration: %.3fs" % (time.time() - t1))

def _subsetschanged(self):
asset_ids = self.data["state"]["assetIds"]
# Skip setting colors if not asset multiselection
Expand Down Expand Up @@ -351,14 +362,6 @@ def closeEvent(self, event):
modifiers = QtWidgets.QApplication.queryKeyboardModifiers()
shift_pressed = QtCore.Qt.ShiftModifier & modifiers

if shift_pressed:
print("Force quitted..")
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

# Kill on holding SHIFT
modifiers = QtWidgets.QApplication.queryKeyboardModifiers()
shift_pressed = QtCore.Qt.ShiftModifier & modifiers

if shift_pressed:
print("Force quitted..")
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Expand Down Expand Up @@ -560,6 +563,8 @@ def cli(args):
args = parser.parse_args(args)
project = args.project

print("Entering Project: %s" % project)

io.install()

# Store settings
Expand Down
Loading

0 comments on commit b3452ed

Please sign in to comment.