Coder Social home page Coder Social logo

Comments (5)

luispedro avatar luispedro commented on May 30, 2024

This is interesting, can you please post an example jugfile.py that I can try running on my side?

from jug.

chenxi-shi avatar chenxi-shi commented on May 30, 2024

Here is an example

import sys
from jug import TaskGenerator
from time import sleep


class tester:
    def __init__(self, a):
        self.a = a

    @TaskGenerator
    def do_something(self, sleep_sec):
        print("Here is a: {}".format(self.a))
        for i in range(1, 1 + sleep_sec):
            sleep(1)
            print("Process: {}/{} sec".format(i, sleep_sec))
        print("Sleeping {}sec Finished".format(sleep_sec))
        return sleep_sec

sleep_task_count = int(sys.argv[1])
t = tester("aaa")
print(type(t))
fullresults = [t.do_something(j) for j in range(1, sleep_task_count + 1, 1)]

from jug.

chenxi-shi avatar chenxi-shi commented on May 30, 2024

This file needs one command line argument, which should be a number (sleep_task_count). The code should totally do (sum(1, ..., sleep_task_count)) seconds of sleep.

from jug.

luispedro avatar luispedro commented on May 30, 2024

Thanks. I'm not sure how/whether this use can be supported.

Naturally, you can use a 1-line wrapper:

class tester:
    def __init__(self, a):
        self.a = a

    def do_something(self, sleep_sec):
        print("Here is a: {}".format(self.a))
        for i in range(1, 1 + sleep_sec):
            sleep(1)
            print("Process: {}/{} sec".format(i, sleep_sec))

@TaskGenerator
def do_something_wrapper(t, sleep_sec):
    return t.do_something(sleep_sec)

I'll see if I can figure out something better...

from jug.

chenxi-shi avatar chenxi-shi commented on May 30, 2024

Hi sorry for the late replying. I just get time to try it. I think your way is good, and I will use it. Thanks!

from jug.

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.