scitran / core

RESTful API
https://scitran.github.io
MIT License
18 stars 18 forks source link

Job improvements #1054

Closed kofalt closed 6 years ago

kofalt commented 6 years ago

Before:

api/jobs/stats

{
    "by-state": {
        "cancelled": 0, 
        "complete": 0, 
        "failed": 0, 
        "pending": 74, 
        "running": 0
    }, 
    "by-tag": [
        {
            "count": 37, 
            "tags": [
                "auto", 
                "dicom-mr-classifier"
            ]
        }, 
        {
            "count": 37, 
            "tags": [
                "auto", 
                "dcm2niix"
            ]
        }
    ], 
    "permafailed": 0
}

After:

api/jobs/stats

{
    "states": {
        "cancelled": 0, 
        "complete": 0, 
        "failed": 0, 
        "pending": 74, 
        "running": 0
    }
}
api/jobs/stats?all=1

{
    "recent": {
        "cancelled": [], 
        "complete": [], 
        "failed": [], 
        "pending": [
            {
                "_id": "5a60d7a9fdc9bc001d4b90fe", 
                "modified": "2018-01-18T17:21:45.923000+00:00"
            }, 
            {
                "_id": "5a60d7a9fdc9bc001d4b90fd", 
                "modified": "2018-01-18T17:21:45.918000+00:00"
            }, 
            {
                "_id": "5a60d7a9fdc9bc00184b9113", 
                "modified": "2018-01-18T17:21:45.448000+00:00"
            }
        ], 
        "running": []
    }, 
    "states": {
        "cancelled": 0, 
        "complete": 0, 
        "failed": 0, 
        "pending": 74, 
        "running": 0
    }, 
    "unique": [
        "auto", 
        "dcm2niix", 
        "dicom-mr-classifier"
    ]
}
api/jobs/stats?last=1&tags=dcm2niix

{
    "recent": {
        "cancelled": [], 
        "complete": [], 
        "failed": [], 
        "pending": [
            {
                "_id": "5a60d7a9fdc9bc001d4b90fd", 
                "modified": "2018-01-18T17:21:45.918000+00:00"
            }
        ], 
        "running": []
    }, 
    "states": {
        "cancelled": 0, 
        "complete": 0, 
        "failed": 0, 
        "pending": 37, 
        "running": 0
    }
}
api/jobs/stats?unique=1

{
    "states": {
        "cancelled": 0, 
        "complete": 0, 
        "failed": 0, 
        "pending": 74, 
        "running": 0
    }, 
    "unique": [
        "auto", 
        "dcm2niix", 
        "dicom-mr-classifier"
    ]
}

Before:

c := api.NewApiKeyClient("localhost:8443:s8zx9pVmOOR7COADuJ", api.InsecureNoSSLVerification)

_, errChan := c.DownloadSimple(
    "jobs/123/config.json", 
    &api.DownloadSource{Writer: NopWriteCloser(new(bytes.Buffer))}
)

Println(<-errChan)
Response body was expected to be of length -1 but was instead 1138

After:

<nil>
codecov-io commented 6 years ago

Codecov Report

Merging #1054 into master will increase coverage by 0.02%. The diff coverage is 97.5%.

@@            Coverage Diff             @@
##           master    #1054      +/-   ##
==========================================
+ Coverage   91.15%   91.18%   +0.02%     
==========================================
  Files          50       50              
  Lines        6896     6928      +32     
==========================================
+ Hits         6286     6317      +31     
- Misses        610      611       +1
nagem commented 6 years ago

LGTM, I left an option for another route we could take if the recent jobs listing by state becomes a problem.