Skip to content

Commit

Permalink
Merge pull request #202 from wguanicedew/dev
Browse files Browse the repository at this point in the history
fix workflow reload
  • Loading branch information
wguanicedew authored Sep 15, 2023
2 parents 5b8efbb + 163793b commit 3af29f8
Show file tree
Hide file tree
Showing 15 changed files with 449 additions and 109 deletions.
4 changes: 2 additions & 2 deletions atlas/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
license_file = LICENSE.rst
description-file = README.md
license_files = LICENSE.rst
description_file = README.md

[bdist_wheel]
universal = true
4 changes: 2 additions & 2 deletions client/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
license_file = LICENSE.rst
description-file = README.md
license_files = LICENSE.rst
description_file = README.md

[bdist_wheel]
universal = true
92 changes: 91 additions & 1 deletion common/lib/idds/common/dict_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
# http://www.apache.org/licenses/LICENSE-2.0OA
#
# Authors:
# - Wen Guan, <[email protected]>, 2020
# - Wen Guan, <[email protected]>, 2020 - 2023

"""
Dict class.
"""

import logging
import pickle
import urllib
import inspect
from enum import Enum

Expand All @@ -23,6 +26,9 @@ def to_dict_l(self, d):
if not d:
return d

if hasattr(d, 'refresh'):
d.refresh()

if hasattr(d, 'to_dict'):
return d.to_dict()
elif isinstance(d, dict):
Expand All @@ -44,6 +50,10 @@ def to_dict(self):
ret = {'class': self.__class__.__name__,
'module': self.__class__.__module__,
'attributes': {}}

if hasattr(self, 'refresh'):
self.refresh()

for key, value in self.__dict__.items():
# print(key)
# print(value)
Expand Down Expand Up @@ -99,16 +109,31 @@ def from_dict(d):
if not d:
return d

# print("from_dict: %s" % str(d))
# print("is_class: %s" % DictClass.is_class(d))
if isinstance(d, DictBase):
d.metadata = d.metadata

if DictClass.is_class(d):
impl = DictClass.load_instance(d)
last_items = {}
for key, value in d['attributes'].items():
# print(key)
if key == 'logger':
continue
elif key == "_metadata":
last_items[key] = value
# elif key == 'output_data':
# continue
else:
value = DictClass.from_dict(value)
setattr(impl, key, value)

# print("last_items: %s" % str(last_items))
for key, value in last_items.items():
value = DictClass.from_dict(value)
setattr(impl, key, value)

return impl
elif DictClass.is_class_method(d):
impl = DictClass.load_instance_method(d)
Expand All @@ -129,3 +154,68 @@ def from_dict(d):
return d

return d


class DictMetadata(DictClass):
def __init__(self):
pass

def add_item(self, key, value):
setattr(self, key, value)

def get_item(self, key, default):
return getattr(self, key, default)


class DictBase(DictClass):
def __init__(self):
self.metadata = DictMetadata()
pass

def add_metadata_item(self, key, value):
self.metadata.add_item(key, value)

def get_metadata_item(self, key, default=None):
return self.metadata.get_item(key, default)

def refresh(self):
pass

def load_metadata(self):
pass

@property
def metadata(self):
return self._metadata

@metadata.setter
def metadata(self, value):
self._metadata = value
self.load_metadata()

def IDDSProperty(self, attribute):
def _get(self, attribute):
self.get_metadata_item(attribute, None)

def _set(self, attribute, value):
self.add_metadata_item(attribute, value)

attribute = property(_get, _set)
return attribute

def serialize(self):
return urllib.parse.quote_from_bytes(pickle.dumps(self))

@staticmethod
def deserialize(obj):
# return urllib.parse.unquote_to_bytes(pickle.loads(obj))
return pickle.loads(urllib.parse.unquote_to_bytes(obj))

def get_class_name(self):
return self.__class__.__name__

def setup_logger(self):
"""
Setup logger
"""
self.logger = logging.getLogger(self.get_class_name())
4 changes: 2 additions & 2 deletions common/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
license_file = LICENSE.rst
description-file = README.md
license_files = LICENSE.rst
description_file = README.md

[bdist_wheel]
universal = true
4 changes: 2 additions & 2 deletions doma/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
license_file = LICENSE.rst
description-file = README.md
license_files = LICENSE.rst
description_file = README.md

[bdist_wheel]
universal = true
2 changes: 1 addition & 1 deletion main/lib/idds/agents/common/plugins/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def connect_to_messaging_brokers(self, sender=True):
for broker, port in broker_addresses:
conn = stomp.Connection12(host_and_ports=[(broker, port)],
keepalive=True,
heartbeats=(60000, 0), # one minute
heartbeats=(30000, 0), # one minute
timeout=timeout)
conns.append(conn)
channel_conns[name] = conns
Expand Down
Loading

0 comments on commit 3af29f8

Please sign in to comment.