Saving results

In just four lines of code, we can setup serialization of collections of PackageAnalyzer's Package object to Apache arrow tables:

julia> using PackageAnalyzer

julia> using Arrow # v1.3+

julia> ArrowTypes.arrowname(::Type{PackageAnalyzer.Package}) = Symbol("JuliaLang.PackageAnalyzer.Package")

julia> ArrowTypes.JuliaType(::Val{Symbol("JuliaLang.PackageAnalyzer.Package")}) = PackageAnalyzer.Package

julia> save(path, packages) = Arrow.write(path, (; packages))
save (generic function with 1 method)

julia> load(path) = copy(Arrow.Table(path).packages)
load (generic function with 1 method)

Then we can do e.g.

julia> results = analyze(find_packages("DataFrames", "Flux"));

julia> save("packages.arrow", results)
"packages.arrow"

julia> roundtripped_results = load("packages.arrow")
2-element Vector{PackageAnalyzer.Package}:
 Package DataFrames:
  * repo: https://github.com/JuliaData/DataFrames.jl.git
  * uuid: a93c6f00-e57d-5684-b7b6-d8193f3e46c0
  * is reachable: true
  * lines of Julia code in `src`: 15790
  * lines of Julia code in `test`: 17504
  * has license(s) in file: MIT
    * filename: LICENSE.md
    * OSI approved: true
  * number of contributors: 172 (and 15 anonymous contributors)
  * has documentation: true
  * has tests: true
  * has continuous integration: true
    * GitHub Actions
 Package Flux:
  * repo: https://github.com/FluxML/Flux.jl.git
  * uuid: 587475ba-b771-5e3f-ad9e-33799f191a9c
  * is reachable: true
  * lines of Julia code in `src`: 5240
  * lines of Julia code in `test`: 2335
  * has license(s) in file: MIT
    * filename: LICENSE.md
    * OSI approved: true
  * number of contributors: 158 (and 7 anonymous contributors)
  * has documentation: true
  * has tests: true
  * has continuous integration: true
    * GitHub Actions
    * Buildkite

Note that even if future versions of PackageAnalyzer change the layout of Package's and you forget the version used to serialize the results, you can use the same load function without defining the ArrowTypes.JuliaType method in the Julia session in order to deserialize the results back as NamedTuple's (instead of as Packages), providing some amount of robustness.