Skip to content

Add priority queue implementation#124

Merged
rmarianski merged 8 commits intomasterfrom
priority-queue
Dec 2, 2016
Merged

Add priority queue implementation#124
rmarianski merged 8 commits intomasterfrom
priority-queue

Conversation

@rmarianski
Copy link
Copy Markdown
Member

Connects to #18

@zerebubuth, @nvkelso, @iandees could you review please?

Instead of using an integer index into the list of queues, use the queue
name itself as the id for mapping purposes.
Comment thread tilequeue/queue/multisqs.py Outdated
def job_done(self, coord_message):
queue_name = self.get_queue_name_for_zoom(coord_message.coord.zoom)
if queue_name is None:
# TODO log? should this assert instead?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should assert here. Presumably this would mean that tilequeue has rendered a zoom level for which it wasn't configured, which seems to me like an error condition. Should we assume that get_queue_name_for_zoom will return a valid queue name always, and have an assertion in that method (or use [] instead of get())?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added assert in 22ea268.

And upon further thought, I think that you're right that we'd want it to fail fast when it didn't find a queue for a particular input. That suggests either the mapping is wrong/incomplete, or the input coordinate is invalid, which I think we'd want to know about right away. I'll go ahead and make this change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated in c4749ef.

Comment thread config.yaml.sample Outdated
# type can be `sqs`, `multisqs`, `file`, `mem`, or `redis`
type: mem
name: <sqs queue/queue file name/redis key>
name: <sqs queue/queue file name/redis key/list of queue names>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This list and the list in the line above should be in the same order.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, updated in b6df7a3.

Comment thread config.yaml.sample
zoom-queue-map:
# keys are <start-zoom>-<end-zoom> (inclusive) ranges
# values are the queue name to use for zooms in that range
0-10: queue-1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should the queue names be descriptive of the zooms, or generic?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is just sample config, but for what we actually do I was planning on using generic names, in descending priority order, ie 1 is higher priority than 2, and so on. That way if we change our mapping policy in the future we won't have to re-create queues to represent the new configuration.

Comment thread tilequeue/command.py

def __call__(self, zoom):
assert isinstance(zoom, int)
assert 0 <= zoom <= 20
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We've standardized around 21 in house styles and Tangram.

Comment thread tilequeue/command.py
except (ValueError, KeyError):
assert not 'Invalid zoom range: %s' % zoom_range

assert (0 <= zoom_start <= 20 and
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto 21

Comment thread tilequeue/queue/sqs.py
coord = deserialize_coord(data)
if coord is None:
# log?
# TODO log?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

;)

Comment thread tilequeue/tile.py


def coord_is_valid(coord):
if coord.zoom < 0 or coord.zoom > 20:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto 21

@nvkelso
Copy link
Copy Markdown
Member

nvkelso commented Dec 2, 2016 via email

@rmarianski
Copy link
Copy Markdown
Member Author

Tracking the zoom 20 -> 21 bump in https://github.com/mapzen/tile-tasks/issues/152

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.

3 participants