feat: move apply to porcelain
feat: move data access to repository feat: object_store layer to repository (with GraphObjectStore) revert: missing network services
This commit is contained in:
parent
8e3c86561f
commit
647ac46c01
@ -47,7 +47,7 @@ from replication.constants import (COMMITED, FETCHED, RP_COMMON, STATE_ACTIVE,
|
|||||||
from replication.data import DataTranslationProtocol
|
from replication.data import DataTranslationProtocol
|
||||||
from replication.exception import ContextError, NonAuthorizedOperationError
|
from replication.exception import ContextError, NonAuthorizedOperationError
|
||||||
from replication.interface import session
|
from replication.interface import session
|
||||||
from replication.porcelain import add
|
from replication.porcelain import add, apply
|
||||||
from replication.repository import Repository
|
from replication.repository import Repository
|
||||||
|
|
||||||
from . import bl_types, environment, timers, ui, utils
|
from . import bl_types, environment, timers, ui, utils
|
||||||
@ -82,8 +82,8 @@ def initialize_session():
|
|||||||
|
|
||||||
# Step 1: Constrect nodes
|
# Step 1: Constrect nodes
|
||||||
logging.info("Constructing nodes")
|
logging.info("Constructing nodes")
|
||||||
for node in session._repository.list_ordered():
|
for node in session.repository.list_ordered():
|
||||||
node_ref = session.get(uuid=node)
|
node_ref = session.repository.get_node(node)
|
||||||
if node_ref is None:
|
if node_ref is None:
|
||||||
logging.error(f"Can't construct node {node}")
|
logging.error(f"Can't construct node {node}")
|
||||||
elif node_ref.state == FETCHED:
|
elif node_ref.state == FETCHED:
|
||||||
@ -91,8 +91,8 @@ def initialize_session():
|
|||||||
|
|
||||||
# Step 2: Load nodes
|
# Step 2: Load nodes
|
||||||
logging.info("Loading nodes")
|
logging.info("Loading nodes")
|
||||||
for node in session._repository.list_ordered():
|
for node in session.repository.list_ordered():
|
||||||
node_ref = session.get(uuid=node)
|
node_ref = session.repository.get_node(node)
|
||||||
|
|
||||||
if node_ref is None:
|
if node_ref is None:
|
||||||
logging.error(f"Can't load node {node}")
|
logging.error(f"Can't load node {node}")
|
||||||
@ -598,14 +598,17 @@ class SessionApply(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
logging.debug(f"Running apply on {self.target}")
|
logging.debug(f"Running apply on {self.target}")
|
||||||
try:
|
try:
|
||||||
node_ref = session.get(uuid=self.target)
|
node_ref = session.repository.get_node(self.target)
|
||||||
session.apply(self.target,
|
apply(session.repository,
|
||||||
force=True,
|
self.target,
|
||||||
force_dependencies=self.reset_dependencies)
|
force=True,
|
||||||
|
force_dependencies=self.reset_dependencies)
|
||||||
if node_ref.bl_reload_parent:
|
if node_ref.bl_reload_parent:
|
||||||
for parent in session._repository.find_parents(self.target):
|
for parent in session.repository.find_parents(self.target):
|
||||||
logging.debug(f"Refresh parent {parent}")
|
logging.debug(f"Refresh parent {parent}")
|
||||||
session.apply(parent, force=True)
|
apply(session.repository,
|
||||||
|
parent,
|
||||||
|
force=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.report({'ERROR'}, repr(e))
|
self.report({'ERROR'}, repr(e))
|
||||||
return {"CANCELED"}
|
return {"CANCELED"}
|
||||||
@ -652,11 +655,11 @@ class ApplyArmatureOperator(bpy.types.Operator):
|
|||||||
nodes = session.list(filter=bl_types.bl_armature.BlArmature)
|
nodes = session.list(filter=bl_types.bl_armature.BlArmature)
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
node_ref = session.get(uuid=node)
|
node_ref = session.repository.get_node(node)
|
||||||
|
|
||||||
if node_ref.state == FETCHED:
|
if node_ref.state == FETCHED:
|
||||||
try:
|
try:
|
||||||
session.apply(node)
|
apply(session.repository, node)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("Fail to apply armature: {e}")
|
logging.error("Fail to apply armature: {e}")
|
||||||
|
|
||||||
@ -921,7 +924,7 @@ classes = (
|
|||||||
def update_external_dependencies():
|
def update_external_dependencies():
|
||||||
nodes_ids = session.list(filter=bl_types.bl_file.BlFile)
|
nodes_ids = session.list(filter=bl_types.bl_file.BlFile)
|
||||||
for node_id in nodes_ids:
|
for node_id in nodes_ids:
|
||||||
node = session.get(node_id)
|
node = session.repository.get_node(node_id)
|
||||||
if node and node.owner in [session.id, RP_COMMON] \
|
if node and node.owner in [session.id, RP_COMMON] \
|
||||||
and node.has_changed():
|
and node.has_changed():
|
||||||
session.commit(node_id)
|
session.commit(node_id)
|
||||||
@ -934,7 +937,7 @@ def sanitize_deps_graph(remove_nodes: bool = False):
|
|||||||
start = utils.current_milli_time()
|
start = utils.current_milli_time()
|
||||||
rm_cpt = 0
|
rm_cpt = 0
|
||||||
for node_key in session.list():
|
for node_key in session.list():
|
||||||
node = session.get(node_key)
|
node = session.repository.get_node(node_key)
|
||||||
if node is None \
|
if node is None \
|
||||||
or (node.state == UP and not node.resolve(construct=False)):
|
or (node.state == UP and not node.resolve(construct=False)):
|
||||||
if remove_nodes:
|
if remove_nodes:
|
||||||
@ -987,7 +990,7 @@ def depsgraph_evaluation(scene):
|
|||||||
# Is the object tracked ?
|
# Is the object tracked ?
|
||||||
if update.id.uuid:
|
if update.id.uuid:
|
||||||
# Retrieve local version
|
# Retrieve local version
|
||||||
node = session.get(uuid=update.id.uuid)
|
node = session.repository.get_node(update.id.uuid)
|
||||||
|
|
||||||
# Check our right on this update:
|
# Check our right on this update:
|
||||||
# - if its ours or ( under common and diff), launch the
|
# - if its ours or ( under common and diff), launch the
|
||||||
@ -1011,7 +1014,7 @@ def depsgraph_evaluation(scene):
|
|||||||
continue
|
continue
|
||||||
# A new scene is created
|
# A new scene is created
|
||||||
elif isinstance(update.id, bpy.types.Scene):
|
elif isinstance(update.id, bpy.types.Scene):
|
||||||
ref = session.get(reference=update.id)
|
ref = session.repository.get_node_by_datablock(update.id)
|
||||||
if ref:
|
if ref:
|
||||||
ref.resolve()
|
ref.resolve()
|
||||||
else:
|
else:
|
||||||
|
@ -30,7 +30,7 @@ import mathutils
|
|||||||
from bpy_extras import view3d_utils
|
from bpy_extras import view3d_utils
|
||||||
from gpu_extras.batch import batch_for_shader
|
from gpu_extras.batch import batch_for_shader
|
||||||
from replication.constants import (STATE_ACTIVE, STATE_AUTH, STATE_CONFIG,
|
from replication.constants import (STATE_ACTIVE, STATE_AUTH, STATE_CONFIG,
|
||||||
STATE_INITIAL, STATE_LAUNCHING_SERVICES,
|
STATE_INITIAL, CONNECTING,
|
||||||
STATE_LOBBY, STATE_QUITTING, STATE_SRV_SYNC,
|
STATE_LOBBY, STATE_QUITTING, STATE_SRV_SYNC,
|
||||||
STATE_SYNCING, STATE_WAITING)
|
STATE_SYNCING, STATE_WAITING)
|
||||||
from replication.interface import session
|
from replication.interface import session
|
||||||
|
@ -23,7 +23,8 @@ from replication.constants import (FETCHED, RP_COMMON, STATE_ACTIVE,
|
|||||||
STATE_INITIAL, STATE_LOBBY, STATE_QUITTING,
|
STATE_INITIAL, STATE_LOBBY, STATE_QUITTING,
|
||||||
STATE_SRV_SYNC, STATE_SYNCING, UP)
|
STATE_SRV_SYNC, STATE_SYNCING, UP)
|
||||||
from replication.exception import NonAuthorizedOperationError, ContextError
|
from replication.exception import NonAuthorizedOperationError, ContextError
|
||||||
from replication.interface import session, add
|
from replication.interface import session
|
||||||
|
from replication.porcelain import apply, add
|
||||||
|
|
||||||
from . import operators, utils
|
from . import operators, utils
|
||||||
from .presence import (UserFrustumWidget, UserNameWidget, UserSelectionWidget,
|
from .presence import (UserFrustumWidget, UserNameWidget, UserSelectionWidget,
|
||||||
@ -110,18 +111,18 @@ class ApplyTimer(Timer):
|
|||||||
nodes = session.list()
|
nodes = session.list()
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
node_ref = session.get(uuid=node)
|
node_ref = session.repository.get_node(node)
|
||||||
|
|
||||||
if node_ref.state == FETCHED:
|
if node_ref.state == FETCHED:
|
||||||
try:
|
try:
|
||||||
session.apply(node)
|
apply(session.repository, node)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Fail to apply {node_ref.uuid}: {e}")
|
logging.error(f"Fail to apply {node_ref.uuid}: {e}")
|
||||||
else:
|
else:
|
||||||
if node_ref.bl_reload_parent:
|
if node_ref.bl_reload_parent:
|
||||||
for parent in session._repository.find_parents(node):
|
for parent in session.repository.find_parents(node):
|
||||||
logging.debug("Refresh parent {node}")
|
logging.debug("Refresh parent {node}")
|
||||||
session.apply(parent, force=True)
|
apply(session.repository, parent, force=True)
|
||||||
|
|
||||||
|
|
||||||
class DynamicRightSelectTimer(Timer):
|
class DynamicRightSelectTimer(Timer):
|
||||||
@ -148,7 +149,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
|
|
||||||
# if an annotation exist and is tracked
|
# if an annotation exist and is tracked
|
||||||
if annotation_gp and annotation_gp.uuid:
|
if annotation_gp and annotation_gp.uuid:
|
||||||
registered_gp = session.get(uuid=annotation_gp.uuid)
|
registered_gp = session.repository.get_node(annotation_gp.uuid)
|
||||||
if is_annotating(bpy.context):
|
if is_annotating(bpy.context):
|
||||||
# try to get the right on it
|
# try to get the right on it
|
||||||
if registered_gp.owner == RP_COMMON:
|
if registered_gp.owner == RP_COMMON:
|
||||||
@ -162,7 +163,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
affect_dependencies=False)
|
affect_dependencies=False)
|
||||||
|
|
||||||
if registered_gp.owner == settings.username:
|
if registered_gp.owner == settings.username:
|
||||||
gp_node = session.get(uuid=annotation_gp.uuid)
|
gp_node = session.repository.get_node(annotation_gp.uuid)
|
||||||
if gp_node.has_changed():
|
if gp_node.has_changed():
|
||||||
session.commit(gp_node.uuid)
|
session.commit(gp_node.uuid)
|
||||||
session.push(gp_node.uuid, check_data=False)
|
session.push(gp_node.uuid, check_data=False)
|
||||||
@ -186,7 +187,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
|
|
||||||
# change old selection right to common
|
# change old selection right to common
|
||||||
for obj in obj_common:
|
for obj in obj_common:
|
||||||
node = session.get(uuid=obj)
|
node = session.repository.get_node(obj)
|
||||||
|
|
||||||
if node and (node.owner == settings.username or node.owner == RP_COMMON):
|
if node and (node.owner == settings.username or node.owner == RP_COMMON):
|
||||||
recursive = True
|
recursive = True
|
||||||
@ -204,7 +205,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
|
|
||||||
# change new selection to our
|
# change new selection to our
|
||||||
for obj in obj_ours:
|
for obj in obj_ours:
|
||||||
node = session.get(uuid=obj)
|
node = session.repository.get_node(obj)
|
||||||
|
|
||||||
if node and node.owner == RP_COMMON:
|
if node and node.owner == RP_COMMON:
|
||||||
recursive = True
|
recursive = True
|
||||||
@ -237,7 +238,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
owned_keys = session.list(
|
owned_keys = session.list(
|
||||||
filter_owner=settings.username)
|
filter_owner=settings.username)
|
||||||
for key in owned_keys:
|
for key in owned_keys:
|
||||||
node = session.get(uuid=key)
|
node = session.repository.get_node(key)
|
||||||
try:
|
try:
|
||||||
session.change_owner(
|
session.change_owner(
|
||||||
key,
|
key,
|
||||||
|
@ -26,7 +26,7 @@ from replication.constants import (ADDED, ERROR, FETCHED,
|
|||||||
STATE_INITIAL, STATE_SRV_SYNC,
|
STATE_INITIAL, STATE_SRV_SYNC,
|
||||||
STATE_WAITING, STATE_QUITTING,
|
STATE_WAITING, STATE_QUITTING,
|
||||||
STATE_LOBBY,
|
STATE_LOBBY,
|
||||||
STATE_LAUNCHING_SERVICES)
|
CONNECTING)
|
||||||
from replication import __version__
|
from replication import __version__
|
||||||
from replication.interface import session
|
from replication.interface import session
|
||||||
from .timers import registry
|
from .timers import registry
|
||||||
@ -441,7 +441,7 @@ class SESSION_PT_presence(bpy.types.Panel):
|
|||||||
def draw_property(context, parent, property_uuid, level=0):
|
def draw_property(context, parent, property_uuid, level=0):
|
||||||
settings = get_preferences()
|
settings = get_preferences()
|
||||||
runtime_settings = context.window_manager.session
|
runtime_settings = context.window_manager.session
|
||||||
item = session.get(uuid=property_uuid)
|
item = session.repository.get_node(property_uuid)
|
||||||
|
|
||||||
area_msg = parent.row(align=True)
|
area_msg = parent.row(align=True)
|
||||||
|
|
||||||
@ -568,7 +568,7 @@ class SESSION_PT_repository(bpy.types.Panel):
|
|||||||
filter_owner=settings.username) if runtime_settings.filter_owned else session.list()
|
filter_owner=settings.username) if runtime_settings.filter_owned else session.list()
|
||||||
|
|
||||||
client_keys = [key for key in key_to_filter
|
client_keys = [key for key in key_to_filter
|
||||||
if session.get(uuid=key).str_type
|
if session.repository.get_node(key).str_type
|
||||||
in types_filter]
|
in types_filter]
|
||||||
|
|
||||||
if client_keys:
|
if client_keys:
|
||||||
|
@ -36,7 +36,7 @@ from replication.constants import (STATE_ACTIVE, STATE_AUTH,
|
|||||||
STATE_INITIAL, STATE_SRV_SYNC,
|
STATE_INITIAL, STATE_SRV_SYNC,
|
||||||
STATE_WAITING, STATE_QUITTING,
|
STATE_WAITING, STATE_QUITTING,
|
||||||
STATE_LOBBY,
|
STATE_LOBBY,
|
||||||
STATE_LAUNCHING_SERVICES)
|
CONNECTING)
|
||||||
|
|
||||||
|
|
||||||
def find_from_attr(attr_name, attr_value, list):
|
def find_from_attr(attr_name, attr_value, list):
|
||||||
@ -92,7 +92,7 @@ def get_state_str(state):
|
|||||||
state_str = 'OFFLINE'
|
state_str = 'OFFLINE'
|
||||||
elif state == STATE_QUITTING:
|
elif state == STATE_QUITTING:
|
||||||
state_str = 'QUITTING'
|
state_str = 'QUITTING'
|
||||||
elif state == STATE_LAUNCHING_SERVICES:
|
elif state == CONNECTING:
|
||||||
state_str = 'LAUNCHING SERVICES'
|
state_str = 'LAUNCHING SERVICES'
|
||||||
elif state == STATE_LOBBY:
|
elif state == STATE_LOBBY:
|
||||||
state_str = 'LOBBY'
|
state_str = 'LOBBY'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user