Skip to content

Commit

Permalink
fixed recursive data mess
Browse files Browse the repository at this point in the history
  • Loading branch information
wasndas committed Jul 5, 2022
1 parent 96cb39d commit 68cb8d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion python/lvmscraper/actor/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def from_config(cls, config, *args, **kwargs):
instance.log.fh.setLevel(0)
instance.log.sh.setLevel(0)

#instance.log.debug("Hello world")
# instance.log.debug(instance.name)

assert isinstance(instance, ScraperActor)
assert isinstance(instance.config, dict)
Expand Down
4 changes: 2 additions & 2 deletions python/lvmscraper/actor/commands/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
async def data(command: Command, ds: DataStore, filter: str):
"""return raw data filtered"""

command.command_id="scraper"
#command.command_id="scraper"

return command.finish( **ds.data(filter) )

Expand All @@ -31,7 +31,7 @@ async def data(command: Command, ds: DataStore, filter: str):
async def fits(command: Command, ds: DataStore, filter:str):
"""return fits data filtered"""

command.command_id="scraper"
#command.command_id="scraper"

return command.finish( cards=ds.asFits(filter) )

15 changes: 6 additions & 9 deletions python/lvmscraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,25 @@ def _flatten_dict_gen(d, parent_key, sep):


class AMQPClientScraper(AMQPClient):
def __init__(self, datastore, **kwargs):
def __init__(self, datastore, name:str="", **kwargs):

self.store = datastore.store
self.ignore = ["text", "help", "schema", "error", "error.exception_message", "error.exception_module", "error.exception_type", "cards", "scraper"]

self.actor_name = name
self.scraper_name = f"{self.actor_name}.listener"

name = f"{kwargs.get('name', 'scraper')}.listener"

super().__init__(name, **{key: val for (key,val) in kwargs.items() if key != 'name'})
super().__init__(self.scraper_name, **{key: val for (key,val) in kwargs.items() if key != 'name'})


async def handle_reply(self, message: apika.IncomingMessage) -> AMQPReply:
"""Handles a reply received from the exchange.
"""
reply = AMQPReply(message, log=self.log)

# print(f"{reply.headers} {reply.sender}")

#if reply.sender == self.actorname:
#return
# self.log.warning(f"{self.name} {reply.headers} {reply.sender} {reply.command_id}")

if reply.command_id == "scraper":
if reply.sender == self.actor_name:
return

body = { key: value for (key,value) in flatten_dict(reply.body).items() if key not in self.ignore}
Expand Down

0 comments on commit 68cb8d1

Please sign in to comment.