Code Monkey home page Code Monkey logo

Comments (3)

michel-kraemer avatar michel-kraemer commented on July 3, 2024 1

The most flexible way should be something like this:

def models = [
    'https://grobid.s3.amazonaws.com/dataseer-binary_bert-0.3.1.zip',
    'https://grobid.s3.amazonaws.com/dataseer-first_bert-0.3.1.zip',
    'https://grobid.s3.amazonaws.com/dataseer-reuse_bert-0.3.1.zip',
    'https://grobid.s3.amazonaws.com/datasets-BERT_CRF-0.3.2.zip',
    'https://grobid.s3.amazonaws.com/context_bert-0.3.2.zip',
    'https://grobid.s3.amazonaws.com/context_bert_used-0.3.2.zip',
    'https://grobid.s3.amazonaws.com/context_bert_creation-0.3.2.zip',
    'https://grobid.s3.amazonaws.com/context_bert_shared-0.3.2.zip'
]

def installModels = tasks.register("installModels")

models.eachWithIndex { model, index ->
    def downloadTask = tasks.register("downloadModel_$index", Download) {
        src(model)
        dest "${projectDir}/models/"
        onlyIfNewer true
        // overwrite true
    }

    def unzipTask = tasks.register("unzipModel_$index", Copy) {
        dependsOn downloadTask
        from zipTree(downloadTask.get().outputs.files.first())
        into "${projectDir}/models/extracted/"
    }

    installModels.get().dependsOn(unzipTask)
}

Creating a separate task for every model has the additional benefit that downloading and unzipping can happen in parallel: as soon as the first model has been downloaded, it can already be unzipped even though the other files are still downloading. Also, using tasks for everything (instead of the download.run extension) helps with caching. If you execute the task again and nothing has changed, it will be skipped with an UP-TO-DATE message.

Please note that I've replaced overwrite true with onlyIfNewer true to avoid downloading the models over and over again. This is probably what you want.

Let me know if this helps and if so, please close the issue. Thanks!

from gradle-download-task.

lfoppiano avatar lfoppiano commented on July 3, 2024

I did this:

doLast {
        print "Copy models under grobid-home: ${grobidHome}"
        download.run {
            src([
                    'https://grobid.s3.amazonaws.com/dataseer-binary_bert-0.3.1.zip',
                    'https://grobid.s3.amazonaws.com/dataseer-first_bert-0.3.1.zip',
                    'https://grobid.s3.amazonaws.com/dataseer-reuse_bert-0.3.1.zip',
                    'https://grobid.s3.amazonaws.com/datasets-BERT_CRF-0.3.2.zip',
                    'https://grobid.s3.amazonaws.com/context_bert-0.3.2.zip',
                    'https://grobid.s3.amazonaws.com/context_bert_used-0.3.2.zip',
                    'https://grobid.s3.amazonaws.com/context_bert_creation-0.3.2.zip',
                    'https://grobid.s3.amazonaws.com/context_bert_shared-0.3.2.zip'
            ])
            dest "${grobidHome}/models/"
            overwrite true

            fileTree(dir: "${grobidHome}/models/", includes: ['*.zip']).each { zipFile ->
                from zipTree(zipFile)
            }
            into "${grobidHome}/models/"
        }
    }

but it does not work, the download works, but not the unzip. 💦

from gradle-download-task.

lfoppiano avatar lfoppiano commented on July 3, 2024

Thanks!

from gradle-download-task.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.