Skip to content
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
2 changes: 1 addition & 1 deletion docs/docs/api-reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ available in EasyScience.
- [fitting](fitting.md) – Fitting and sampling, including `Fitter`,
`Sampler` and the available minimizers.
- [global_object](global_object.md) – Global singleton providing shared
services (logger, map, undo/redo stack, script manager).
services (logger, object registry, undo/redo stack, script manager).
- [job](job.md) – Job and experiment abstractions for running and
organizing analyses.
- [utils](utils.md) – Miscellaneous utility functions and helpers (class
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/user-guide/parameter-dependency-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ reported the same way, with the underlying error message appended.
first and call `resolve_all_parameter_dependencies` on the collection
as a whole.
- **Keep the referenced objects alive.** Lookup goes through the global
object map, so a parameter that has been garbage-collected cannot be
found.
object registry, so a parameter that has been garbage-collected cannot
be found.
- **Do not load the same data twice in one session.** Serializer ids are
restored verbatim. If the original parameters, or an earlier load of
the same file, are still alive, a dependency can be bound to that
Expand Down
2 changes: 1 addition & 1 deletion src/easyscience/base_classes/model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class definition.
try:
temp_param = getattr(cls_instance, key)
setattr(cls_instance, '_' + key, value)
cls_instance._global_object.map.prune(temp_param.unique_name)
cls_instance._global_object.registry.discard(temp_param.unique_name)
except Exception as e:
raise SyntaxError(f"""Could not set parameter {key} during `from_dict` with full deserialized variable. \n'
This should be fixed in the class definition. Error: {e}""") from e
Expand Down
6 changes: 3 additions & 3 deletions src/easyscience/base_classes/new_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, unique_name: Optional[str] = None, display_name: Optional[str
if not isinstance(unique_name, str):
raise TypeError('Unique name has to be a string.')
self._unique_name = unique_name
self._global_object.map.add_vertex(self, obj_type='created')
self._global_object.registry.add(self)
if display_name is not None and not isinstance(display_name, str):
raise TypeError('Display name must be a string or None')
self._display_name = display_name
Expand All @@ -51,7 +51,7 @@ def unique_name(self, new_unique_name: str):
"""
Set a new unique name for the object.

The old name is still kept in the map.
The old name is still kept in the registry.

Parameters
----------
Expand All @@ -66,7 +66,7 @@ def unique_name(self, new_unique_name: str):
if not isinstance(new_unique_name, str):
raise TypeError('Unique name has to be a string.')
self._unique_name = new_unique_name
self._global_object.map.add_vertex(self)
self._global_object.registry.add(self)
self._default_unique_name = False

@property
Expand Down
2 changes: 1 addition & 1 deletion src/easyscience/global_object/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

from .global_object import GlobalObject # noqa: F401
from .logger import Logger # noqa: F401
from .map import Map # noqa: F401
from .object_registry import ObjectRegistry # noqa: F401
from .undo_redo import UndoStack # noqa: F401
12 changes: 5 additions & 7 deletions src/easyscience/global_object/global_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from ..utils.classUtils import singleton
from .logger import Logger
from .map import Map
from .object_registry import ObjectRegistry


@singleton
Expand All @@ -16,7 +16,7 @@ class GlobalObject:
"""

__log = Logger()
__map = Map()
__registry = ObjectRegistry()
__stack = None
__debug = False

Expand All @@ -27,8 +27,8 @@ def __init__(self):
self.debug: bool = self.__debug
# Stack. This is where the undo/redo operations are stored.
self.stack = self.__stack
# Map. This is the conduit database between all global object species
self.map: Map = self.__map
# Registry. All live EasyScience objects, looked up by unique name
self.registry: ObjectRegistry = self.__registry

def instantiate_stack(self):
"""
Expand Down Expand Up @@ -56,9 +56,7 @@ def generate_unique_name(self, name_prefix: str) -> str:
str
Generated unique name.
"""
names_with_prefix = [
name for name in self.map.vertices() if name.startswith(name_prefix + '_')
]
names_with_prefix = [name for name in self.registry if name.startswith(name_prefix + '_')]
if names_with_prefix:
name_with_prefix_count = [0]
for name in names_with_prefix:
Expand Down
Loading
Loading