Skip to content

replace staticmethod with classmethod in get_dataset_splits() #291

@mariosasko

Description

@mariosasko

Currently, get_dataset_splits() in our datasets is a static method (@staticmethod), but it would be more appropriate to have it marked as a class method (@classmethod).

The following example shows the difference between these two:

class A:
    @staticmethod
    def x():
         A.y()

    @staticmethod
    def y():
        print('Ay')

class B(A):
    @staticmethod
    def y():
        print('By')

B.x() prints Ay

class A:
    @classmethod
    def x(cls):
         cls.y()

    @staticmethod
    def y():
        print('Ay')

class B(A):
    @staticmethod
    def y():
        print('By')

B.x() prints By

In our datasets, x corresponds to get_dataset_splits and y corresponds to get_default_fields. The issue is that our current pattern doesn't support overriding get_default_fields by a subclass as can be seen in the example above (replace print with return fields), without overriding get_dataset_splits as well. We have this scenario in the SNLI dataset so this is the main reason why I'm opening this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    datasetIssues or pull requests related to datasets

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions