oxinabox / DataDepsGenerators.jl

Utility for developers to help define DataDeps registration blocks, for reusing existing Data with DataDeps.jl
Other
18 stars 6 forks source link

Support projects at osf.io #72

Open dmbates opened 5 years ago

dmbates commented 5 years ago

I have done some exploring of the API at https://api.osf.io. The way that I would see generating a DataDep for files in a project on that site is

and, within that directory, the files to download

julia> JSON.print(JSON.parse(String(HTTP.get("https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfc325e63c0019e40676/").body)),2)
{
  "data": [
    {
      "links": {
        "delete": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfd384f087001cdb4514",
        "download": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfd384f087001cdb4514",
        "upload": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfd384f087001cdb4514?kind=file",
        "move": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfd384f087001cdb4514"
      },
      "attributes": {
        "path": "/5b7adfd384f087001cdb4514",
        "resource": "kz483",
        "name": "pb2_n0.rda",
        "contentType": "application/octet-stream",
        "etag": "837bdf186ba88e402c0d273a2d9f5c62d3bad67b44bbc97dc4d3501eab01d78a",
        "extra": {
          "downloads": 4,
          "latestVersionSeen": null,
          "checkout": null,
          "hashes": {
            "sha256": "1ceb4c1defde581b0b4cf89725fb665b618d0fab47c900875731480632e60284",
            "md5": "1efd49f796f39427c53719cbc45dd425"
          },
          "guid": null,
          "version": 1
        },
        "modified_utc": "2018-08-20T15:35:47.815296+00:00",
        "created_utc": "2018-08-20T15:35:47.815296+00:00",
        "size": 417405,
        "provider": "osfstorage",
        "kind": "file",
        "modified": "2018-08-20T15:35:47.815296+00:00",
        "sizeInt": 417405,
        "materialized": "/R_Data/pb2_n0.rda"
      },
      "id": "osfstorage/5b7adfd384f087001cdb4514",
      "type": "files"
    },
    {
      "links": {
        "delete": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfdb84f087001bdb429d",
        "download": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfdb84f087001bdb429d",
        "upload": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfdb84f087001bdb429d?kind=file",
        "move": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfdb84f087001bdb429d"
      },
      "attributes": {
        "path": "/5b7adfdb84f087001bdb429d",
        "resource": "kz483",
        "name": "pb2_n1.rda",
        "contentType": "application/octet-stream",
        "etag": "1158afb0ab29e41be2eaef74a2d63a8a02fd55d5b1828017dc20461223bed9db",
        "extra": {
          "downloads": 3,
          "latestVersionSeen": null,
          "checkout": null,
          "hashes": {
            "sha256": "ba12a76ded3720182864505095e607e62228ea4d9ed2afedcd3b4771c13e33be",
            "md5": "a58ac2e0a9092feea70f14590146d711"
          },
          "guid": null,
          "version": 1
        },
        "modified_utc": "2018-08-20T15:35:55.705473+00:00",
        "created_utc": "2018-08-20T15:35:55.705473+00:00",
        "size": 359380,
        "provider": "osfstorage",
        "kind": "file",
        "modified": "2018-08-20T15:35:55.705473+00:00",
        "sizeInt": 359380,
        "materialized": "/R_Data/pb2_n1.rda"
      },
      "id": "osfstorage/5b7adfdb84f087001bdb429d",
      "type": "files"
    },
    {
      "links": {
        "delete": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfe025e63c0019e406a1",
        "download": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfe025e63c0019e406a1",
        "upload": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfe025e63c0019e406a1?kind=file",
        "move": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfe025e63c0019e406a1"
      },
      "attributes": {
        "path": "/5b7adfe025e63c0019e406a1",
        "resource": "kz483",
        "name": "pb2_n2.rda",
        "contentType": "application/octet-stream",
        "etag": "baba1dbf08c5a0b6c90d233419c8116e88ff998e7136b8feef2ab6b4d2257db8",
        "extra": {
          "downloads": 2,
          "latestVersionSeen": null,
          "checkout": null,
          "hashes": {
            "sha256": "d2de410cfebed370bf4f525512f847991c7ed2a7bc20a71a43aa36f6e689d571",
            "md5": "513c3603111f2ff821ff7f32de53393d"
          },
          "guid": null,
          "version": 1
        },
        "modified_utc": "2018-08-20T15:36:00.347061+00:00",
        "created_utc": "2018-08-20T15:36:00.347061+00:00",
        "size": 326401,
        "provider": "osfstorage",
        "kind": "file",
        "modified": "2018-08-20T15:36:00.347061+00:00",
        "sizeInt": 326401,
        "materialized": "/R_Data/pb2_n2.rda"
      },
      "id": "osfstorage/5b7adfe025e63c0019e406a1",
      "type": "files"
    },
    {
      "links": {
        "delete": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfe484f087001cdb4531",
        "download": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfe484f087001cdb4531",
        "upload": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfe484f087001cdb4531?kind=file",
        "move": "https://files.osf.io/v1/resources/kz483/providers/osfstorage/5b7adfe484f087001cdb4531"
      },
      "attributes": {
        "path": "/5b7adfe484f087001cdb4531",
        "resource": "kz483",
        "name": "typeNgramfreqs.RData",
        "contentType": "application/octet-stream",
        "etag": "a99e130396dd632feb2fd8fc9084336add922bb57b38f0d9bf722112d38c7261",
        "extra": {
          "downloads": 6,
          "latestVersionSeen": null,
          "checkout": null,
          "hashes": {
            "sha256": "f5511bc475d89358f1bcf7cd15d01aee7d5e228b28477c5079115d57a4e9f695",
            "md5": "659538398510833d7c461a49143a0a45"
          },
          "guid": null,
          "version": 1
        },
        "modified_utc": "2018-08-20T15:36:04.354320+00:00",
        "created_utc": "2018-08-20T15:36:04.354320+00:00",
        "size": 11646,
        "provider": "osfstorage",
        "kind": "file",
        "modified": "2018-08-20T15:36:04.35432+00:00",
        "sizeInt": 11646,
        "materialized": "/R_Data/typeNgramfreqs.RData"
      },
      "id": "osfstorage/5b7adfe484f087001cdb4531",
      "type": "files"
    }
  ]
}

The actual download link has a hexadecimal name but the information on what it should be named as a file is available in the attributes.

@oxinabox Can you tell me if you think this would fit in with the DataDepsGenerators scheme and, if so, where I should start?

oxinabox commented 5 years ago

Yes, this look like it should work well.

Take a look at https://github.com/oxinabox/DataDepsGenerators.jl/blob/master/src/APIs/Figshare.jl

Or really anything else from the APIs folder. There are basically a set of methods to overload. To add support for a new API generator.

You can see how all the methods get invoked Here https://github.com/oxinabox/DataDepsGenerators.jl/blob/master/src/generate.jl#L71