Skip to content
Snippets Groups Projects
  1. Jan 07, 2022
  2. Dec 22, 2021
  3. Dec 15, 2021
  4. Dec 08, 2021
  5. Dec 01, 2021
  6. Nov 05, 2021
    • vlorentz's avatar
      Give model and swhid objects a nicer repr() · 2ffe5dba
      vlorentz authored
      1. hashes are now repr()ed as `hash_to_bytes("1234...")` instead of b"\x12\x34..."`
      2. SWHID objects are now repr()ed as `CoreSWHID.from_string('swh:1:...:1234...')`
         instead of `CoreSWHID(scheme='swh', version='1', object_type=..., object_id=b'\x12\x34')`
      3. enums are now repr()ed as `MyEnum.NAME` instead of "<MyEnum.NAME: 'value'>`
      
      Thanks to these three changes, using repr() on a model object now prints
      a string that can be pasted directly in a `.py` file to write a new
      test case.
      2ffe5dba
  7. Oct 01, 2021
    • vlorentz's avatar
      type_validator: Re-allow subclasses · 916627e1
      vlorentz authored
      The previous replaced attrs-strict's type validator with our own,
      stricter and faster, validator.
      
      However, the strictness can be a burden in other packages;
      for example, swh-storage tests rely on it to insert dummy data that raises
      exception when accessed, and it would be hard to do while using the exact
      expected type.
      
      This commit reverts the strict behavior, but keeps the performance
      optimization, by always checking with type equality, but in case type
      equality fails (which would raise an error before this commit), it gives
      the value a 'second chance', by trying isinstance.
      
      This means that, outside tests, isinstance should not be used at all,
      or very rarely.
      916627e1
  8. Sep 28, 2021
    • vlorentz's avatar
      model: Replace attrs-strict with stricter validation · 734b0812
      vlorentz authored
      This reimplements attrs_strict.type_validator(), using type equality
      instead of isinstance.
      
      This makes my checksum validation script (that mostly just instantiates
      model objects, computes a checksum, then discard) run twice as fast.
      734b0812
  9. Sep 23, 2021
    • vlorentz's avatar
      Deprecate identifiers.py · f56becc1
      vlorentz authored
      1. Add a warning
      2. Move identifier/manifest documentation to git_objects.py
      3. Remove all imports of that module.
      
      Motivation:
      
      * SWHID classes were moved to swhids.py
      * manifest computation functions were moved to git_objects.py
      * Only reexports and trivial wrappers of model.py remain
      f56becc1
  10. Jun 15, 2021
  11. Mar 18, 2021
  12. Mar 12, 2021
  13. Mar 08, 2021
  14. Mar 04, 2021
  15. Mar 01, 2021
  16. Dec 30, 2020
    • Stefano Zacchiroli's avatar
      SWHID parsing: simplify and deduplicate validation logic · 57468505
      Stefano Zacchiroli authored
      Before this change there was a lot of overlap between parse_swhid() and the
      attrs-based validators in the SWHID class. Also, the validation implementation
      in parse_swhid() was done by hand.
      
      With this change the coarse-grained validation done by parse_swhid() is now
      delegated to a regex. The semantic validation of SWHIDs is left to attrs
      validators. The regex is also exposed as a module attribute, to be used by
      client code that want to syntactically validate SWHIDs without necessarily
      instantiate SWHID classes (we have several other modules doing that already,
      and they are using slightly different hand-made regexs, which isn't great).
      
      As part of this change we also clean up the use of ValidationError exceptions,
      systematically passing the problematic parts of SWHID as arguments, and uniform
      error messages.
      
      This change also brings some speed up in SWHID parsing. On a benchmark parsing
      ~30 M valid SWHIDs, the previous implementation took ~3:06 minutes, the new one
      ~2:50 minutes, or a ~9% speedup.
      
      Closes T2788
      57468505
  17. Nov 16, 2020
  18. Oct 26, 2020
  19. Oct 08, 2020
    • vlorentz's avatar
      Add a 'unique_key' method on model objects · a251df2e
      vlorentz authored
      that returns a value suitable for unicity constraints.
      
      Motivation:
      
      * this is somewhat more of a model concern than a journal/kafka
        concern IMO
      * this is one step toward adding support for non-model objects in
        KafkaJournalWriter
      
      Implementation of the unique_key methods comes from
      `swh.journal.serializers.object_key`.
      v0.7.1
      a251df2e
  20. Sep 17, 2020
  21. Aug 14, 2020
    • vlorentz's avatar
      model: Raise error on naive datetimes. · 6dd6acec
      vlorentz authored
      We may unknowingly pass naive datetimes to the storage through them,
      causing the underlying DB to assign them a timezone that might not match
      the actual one.
      
      It already happens in swh.model and swh.loader.package tests.
      6dd6acec
  22. Jul 29, 2020
  23. Jul 07, 2020
  24. Jul 06, 2020
    • David Douard's avatar
      Extract the extra_headers from metadata on the Revision model class · a7d9aca2
      David Douard authored
      Add a new extra_headers attribute on Revision and use it for computing
      the revision's id instead of extract it from the metadata field.
      
      Only accept (bytes, bytes) as extra_header.
      
      Add a post init hook to Revision to initialize this new attribute from
      given metadata, if any, for bw compat.
      
      Also amend the revision_d hyptothesis strategy to generate extra_headers.
      v0.4.0
      a7d9aca2
  25. Jun 24, 2020
  26. May 20, 2020
    • David Douard's avatar
      Add support for model object anonymization · 29312dff
      David Douard authored
      Simply add a BaseModel.anonymize() method. Default implementation returns
      None, meaning the object is not anonymizable.
      
      For Person, the method returns a Person whith hashed fullname (and unset
      name and email).
      
      For Revision and Release, the method returns an anonymized version of
      the object, i.e. with instance of Person replaced by anonymized ones.
      v0.2.0
      29312dff
  27. Apr 10, 2020
  28. Apr 08, 2020
    • David Douard's avatar
      Enable black · bf3f1cec
      David Douard authored
      - blackify all the python files,
      - enable black in pre-commit,
      - add a black tox environment.
      bf3f1cec
  29. Apr 01, 2020
Loading