Giter Site home page Giter Site logo

Unwanted imports about qmt HOT 4 CLOSED

microsoft avatar microsoft commented on May 22, 2024
Unwanted imports

from qmt.

Comments (4)

johnkgamble avatar johnkgamble commented on May 22, 2024

OK, this should be fixed as of the latest commit - can you check?

from qmt.

donjan avatar donjan commented on May 22, 2024

Can't test the specific issue due to things not working generally.
Using the first section of an example sent by Spencer last week:

from qmt.tasks import Task, SweepManager

class HelloWorldTask(Task):
    def __init__(self):
        super().__init__()
    def _solve_instance(self, inputs, options):
        print("Hello World")

hi = HelloWorldTask()
em = SweepManager.create_empty_sweep()
print(hi.run_daskless())

If I try to run it as-is:

$ python3 foo.py
Traceback (most recent call last):
  File "foo.py", line 15, in <module>
    print(hi.run_daskless())
  File "/home/donjan/ETH/PhD/code/qmt/qmt/tasks/task.py", line 298, in run_daskless
    self.daskless_result = self.__class__._solve_instance(input_result_list, self.options)
TypeError: _solve_instance() missing 1 required positional argument: 'options'

Removing the self, part from _solve_instance yields:

$ python3 foo.py
Hello World
None

Now using dask:

from qmt.tasks import Task, SweepManager

class HelloWorldTask(Task):
    def __init__(self):
        super().__init__()
    def _solve_instance(inputs, options):
        print("Hello World")

hi = HelloWorldTask()
em = SweepManager.create_empty_sweep()
print(em.run(hi))

Gives:

$ python3 foo.py
Traceback (most recent call last):
  File "foo.py", line 14, in <module>
    print(em.run(hi))
  File "/home/donjan/ETH/PhD/code/qmt/qmt/tasks/sweep.py", line 92, in run
    return task._run()
  File "/home/donjan/ETH/PhD/code/qmt/qmt/tasks/task.py", line 258, in _run
    self.computed_result = self.delayed_result.calculate_futures(resources=self.resources)
  File "/home/donjan/ETH/PhD/code/qmt/qmt/tasks/sweep.py", line 237, in calculate_futures
    futures.append(self.dask_client.compute(delayed_result, resources=resources))
AttributeError: 'NoneType' object has no attribute 'compute'

Can you confirm that these snippets work for you?

from qmt.

johnkgamble avatar johnkgamble commented on May 22, 2024

Ah, I managed to break some stuff yesterday :) . It's fixed now. Yes, you should no longer use "self" in the _solve_instance methods, as they are static now to make it easier for Dask to work with them. Give it a try now; your snippet above now works for me.

from qmt.

donjan avatar donjan commented on May 22, 2024

Looks good now, everything works in Python3.
One QMS import left in qmt/geometry/freecad/run.py, but I assume this is a conscious decision to keep the region mapping code in QMS.

I've added @staticmethod to the _solve_instance of Task derivatives currently in QMT, in accordance to the base class. (Python3 miraculously doesn't complain)

from qmt.

Related Issues (16)

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.