Opened 7 years ago

Closed 5 months ago

#8306 closed enhancement (duplicate)

Format sanitized bridge descriptors and Torperf measurement results

Reported by: karsten Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Normal Keywords: descriptors easy
Cc: Actual Points:
Parent ID: #8252 Points:
Reviewer: Sponsor:

Description

Stem has lots of code for parsing dir-spec.txt objects and metrics-related extensions. I could also make use of functionality to build objects, either based on previously parsed descriptors, or from scratch. I'd use this functionality to create sanitized bridge descriptors (where the order of keywords should be preserved, but where I can replace arguments or add/remove keywords), to format Torperf measurement results, etc. There would likely be just a single application using this code, but it seems useful to maintain this code together with the parsing code. There's no metrics-lib equivalent for this.

Child Tickets

Change History (4)

comment:1 Changed 7 years ago by atagar

Keywords: descriptors easy added

Certainly very easy to do. I'm gonna leave this to potential volunteers for now but if this ever becomes the slightest thorn in your side then let me know and I'll make it so.

At a guess what we'll want is...

  • A new static method on the Descriptor class, of the form 'create_from(attr, instance = None)'. Attr could be either a Descriptor or dict. The instance is an optional copy of a descriptor we're cloning to (a fresh instance is created if None).

All this method does is call setattr() to clone all of the attributes from the attr to the instance.

  • All Descriptor subclasses would want to override create_from() so when instance is undefined they create one of their own type. For instance, the RelayDescriptor's copy might look like...
def create_from(attr, instance = None):
  if instance is None:
    instance = RelayDescriptor()

  if not isinstance(instance, RelayDescriptor):
    raise ValueError("RelayDescriptor.create_from() can only clone to a RelayDescriptor")

  return Descriptor.create_from(attr, instance)
  • We'll need to shift stuff around in all of the init methods to allow us to create empty descriptors (the current parsing stuff should probably be moved to static methods).

If someone wants to take this up then feel free to ask me if you have any questions.

comment:2 Changed 2 years ago by teor

Severity: Normal

Set all open tickets without a severity to "Normal"

comment:3 in reply to:  1 Changed 5 months ago by guigom

Replying to atagar:

If someone wants to take this up then feel free to ask me if you have any questions.

I would like to volunteer on this one. I have only made a couple of contributions in core tor but haven't looked much into stem yet so I would need to spend some time reading.

I would like to ask a couple of questions:

  • A pull request to the github repo would be ok or is a patch preferred?
  • How is a test for this enhancement to be implemented? (I should probably take a look inside test/ folder)
Version 0, edited 5 months ago by guigom (next)

comment:4 Changed 5 months ago by atagar

Resolution: duplicate
Status: newclosed

Oops! I'm sorry guigom, this ticket is ancient, and since then we've already added a Descriptor.create method that would fulfill karsten's original ask...

https://stem.torproject.org/tutorials/mirror_mirror_on_the_wall.html#can-i-create-descriptors

My bad. I should've resolved this a while ago.

To anser your questions...

A pull request to the github repo would be ok or is a patch preferred?

GitHub repos are preferred over patch files, but not a big whoop either way.

https://stem.torproject.org/faq.html#how-do-i-get-started

How is a test for this enhancement to be implemented? (I should probably take a look inside test/ folder)

Yup, tests for new features are appreciated. For instructions on our tests see...

https://stem.torproject.org/faq.html#how-do-i-run-the-tests

Note: See TracTickets for help on using tickets.