Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ZeroMQ message bus in lieu of build queue using new BuildManager #29

Merged
merged 26 commits into from
Apr 8, 2018

Conversation

mpacer
Copy link
Collaborator

@mpacer mpacer commented Mar 18, 2018

If #28 is merged this supercedes #25

This takes the works pursued in #25 and builds off of the work in #28 to have a build manager class that more directly exposes the structure of its subprocesses.

@mpacer mpacer force-pushed the zmq_bus_build_manager branch 9 times, most recently from a56ba17 to 2034f0f Compare March 19, 2018 23:53
@mpacer mpacer mentioned this pull request Mar 20, 2018
@mpacer
Copy link
Collaborator Author

mpacer commented Mar 25, 2018

@stefanv is there anything else that we should accomplish in this PR?

@mpacer mpacer changed the title WIP: Use ZeroMQ message bus in lieu of build queue using new BuildManager Use ZeroMQ message bus in lieu of build queue using new BuildManager Apr 8, 2018
@mpacer
Copy link
Collaborator Author

mpacer commented Apr 8, 2018

@stefanv I think that this is good to go should I merge it?

Copy link
Member

@stefanv stefanv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me overall. I left a few editorial comments.

class Listener:
""" Listener class for defining zmq sockets and maintaining a build queue.

Attributes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the NumPy documentation format, also below.

"""
while True:
msg = await self.socket.recv_multipart()
target, raw_payload = msg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use consistent naming for prefix or target or channel (or whatever you decide is best).

msg = await self.socket.recv_multipart()
target, raw_payload = msg
payload = json.loads(raw_payload.decode('utf-8'))
print('received', payload)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug statement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll remove it, I found it useful even when it was running to know that it was receiving things appropriately and it would show up in the heroku logs (I think). But I'm ok abandoning this.

in_queue = True
return in_queue

def check_age_and_queue(self, nr):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend removing this method and use these two functions inline above. It doesn't add enough to warrant its own function.

# await an item from the queue
nr = await self.queue.get()
# launch subprocess to build item
with ThreadPoolExecutor(max_workers=1) as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many CPUs do we have on Heroku? We could ramp this up, if multiple are available.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When i just ran heroku run grep -c processor /proc/cpuinfo I got 8 back… but I don't know if that will use up our dyno hours more quickly

@mpacer
Copy link
Collaborator Author

mpacer commented Apr 8, 2018

Note the test failure does not actually mean anything since we have nothing setup with travis…

main context for the listener class
socket: zmq.socket
the socket for listening to
queue: asyncio.Queue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how forgiving numpydoc is, but you might need spaces after the parameter name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

@@ -7,21 +7,20 @@
class BuildRequestSubmitter:
"""Class for submitting build requests to zmq socket.

Parameters:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Section should be Parameters.

@mpacer mpacer force-pushed the zmq_bus_build_manager branch 3 times, most recently from d6a7ae8 to 3005978 Compare April 8, 2018 23:17
@mpacer mpacer mentioned this pull request Apr 8, 2018
"""
age = file_age(status_file(nr))
min_wait = 0.5
too_young = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

too_young = (age is not None) and (age <= min_wait)
if too_young:
    log(f"...")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@mpacer mpacer force-pushed the zmq_bus_build_manager branch 3 times, most recently from 47f75fb to eb2db70 Compare April 8, 2018 23:48
@stefanv stefanv merged commit 561fe01 into scipy-conference:master Apr 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants