Any one had success in getting the `ray` library t...
# ask-metaflow
b
Any one had success in getting the
ray
library to work with metaflow on apple silicon? I get the error message
Copy code
nothing provides requested ray-tune 2.3.0
when attempting to include
"ray-tune": "2.3.0",
in the
@conda_base
decorator with PYTHON_VERSION = "3.10.13". I am able to successfully construct a conda python
3.10.13
environment with ray-tune 2.3.0
d
what is the full environment you are trying to work with?
c
This just ran on a mac with M1 chip
Copy code
from metaflow import FlowSpec, step, conda_base

@conda_base(
    python='3.10.13', 
    libraries={
        'ray-tune': '2.3.0'
    }
)
class RayAppleSiliconSmokeTest(FlowSpec):

    @step
    def start(self):
        import ray
        ray.init()
        self.next(self.end)

    @step
    def end(self):
        pass

if __name__ == '__main__':
    RayAppleSiliconSmokeTest()
b
Thanks @crooked-jordan-29960 and @glamorous-night-24898! Here is the set of dependencies
Copy code
TRAINING_PACKAGES = {
    "pandas": "2.1.1",
    "pyarrow": "11.0.0",
    "numpy": "1.26.0",
    "s3fs": "2023.4.0",
    "transformers": "4.32.1",
    "datasets": "2.14.6",
    "pytorch::pytorch": "2.1.1",
    "accelerate": "0.24.1",
    "conda-forge::hyperopt": "0.2.7",  
    "ray-tune": "2.3.0",
}

PYTHON_VERSION = "3.10.13"

@project(name="my_project")
@conda_base(packages=TRAINING_PACKAGES, python=PYTHON_VERSION)
Hmm, when I attempt to run the smoke test flow, here's what I get
Copy code
(py3.10) (base) cearl@cearl-MacBook-Pro % python --version
Python 3.10.13
(py3.10) (base) cearl@cearl-MacBook-Pro % python src/extraction/smoke_test_flow.py --environment=conda run
Metaflow 2.10.8 executing RayAppleSiliconSmokeTest for user:cearl
Validating your flow...
    The graph looks good!
Running pylint...
    Pylint not found, so extra checks are disabled.
Bootstrapping virtual environment(s) ...
    Micromamba ran into an error while setting up environment:
    command '/Users/cearl/.metaflowconfig/micromamba/bin/micromamba create --yes --quiet --dry-run --no-extra-safety-checks --repodata-ttl=86400 --retry-clean-cache --prefix=/var/folders/0r/h_wgmt5j18z8t37d0kg2tr5c0000gn/T/tmpck71h5oq/prefix --channel=conda-forge requests==>=2.21.0 boto3==>=1.14.0 ray-tune==2.3.0 python==3.10.13' returned error (1)
    nothing provides requested ray-tune 2.3.0
👀 1
c
How did you install micromamba? This runs on my macbook 🤔
Copy code
micromamba create --yes --quiet --dry-run --no-extra-safety-checks --repodata-ttl=86400 --retry-clean-cache --prefix=/var/folders/0r/h_wgmt5j18z8t37d0kg2tr5c0000gn/T/tmpck71h5oq/prefix --channel=conda-forge ray-tune==2.3.0 python==3.10.13
b
Interesting. I have no recollection of the micromamba install. Will remove and give another go.
Sigh. Hmm
Copy code
(try-ray-tune) cearl@cearl-MacBook-Pro  % micromamba create --yes --quiet --dry-run --no-extra-safety-checks --repodata-ttl=86400 --retry-clean-cache --prefix=/var/folders/0r/h_wgmt5j18z8t37d0kg2tr5c0000gn/T/tmpck71h5oq/prefix --channel=conda-forge ray-tune==2.3.0 python==3.10.13
error    libmamba Could not solve for environment specs
    The following package could not be installed
    └─ ray-tune 2.3.0  does not exist (perhaps a typo or a missing channel).
error    libmamba Could not solve for environment specs
    The following package could not be installed
    └─ ray-tune 2.3.0  does not exist (perhaps a typo or a missing channel).
critical libmamba Could not solve for environment specs
(try-ray-tune) cearl@cearl-MacBook-Pro address_extraction % micromamba --version
1.5.3
So I guess this is a question to ask in ray channels
Wondering if running via pypi would work.
c
possibly, ray has been spotty with conda in my experience, but they distribute through pypi as first class. if it is ok for your workflow I'd check that route
d
micromamba can be weird too — so it’s not always on the package maintainers. You can try with mamba/conda which sometimes have better compatibility (I know, it’s weird since it shares some code with mamba at least) with the bleeding edge decorators. If you hae mamba and can resolve that enviornment, it may also work that way.
b
Well pypi had the same result
Copy code
from metaflow import FlowSpec, step, pypi


class RayAppleSiliconSmokeTest(FlowSpec):
    @pypi(python="3.10.13", packages={"ray-tune": "2.3.0"})
    @step
    def start(self):
        import ray

        ray.init()
        self.next(self.end)

    @step
    def end(self):
        pass


if __name__ == "__main__":
    RayAppleSiliconSmokeTest()
Copy code
Metaflow 2.10.8 executing RayAppleSiliconSmokeTest for user:cearl
Validating your flow...
    The graph looks good!
Running pylint...
    Pylint not found, so extra checks are disabled.
Bootstrapping virtual environment(s) ...
    Pip ran into an error while setting up environment:

    ERROR: Could not find a version that satisfies the requirement ray-tune==2.3.0 (from versions: none)
    ERROR: No matching distribution found for ray-tune==2.3.0
d
The package may be called
ray[tune]
. I don’t know if it makes a difference.
this 1
So: • for conda: package is
ray-tune
• for pypi: package is
ray[tune]
For both, you can also try: https://docs.metaflow.org/scaling/dependencies/libraries#bleeding-edge-versions-of-the-decorators if it doesn’t work. It may not work but you will get more detail with
METAFLOW_DEBUG_CONDA=1
as an env var which can help debug. The pypi path of both decorators is similar so I wouldn’t expect much difference there but it may help with the conda version.
b
Virtual environment(s) bootstrapped!
Woot!
woohoo 1
d
awesome!
b
Thanks so much 👏
So...I guess the idea of specifying *.whl files is a bit off.
d
Whr do you mean?
b
For example a local library packaged up by setup.py, etc. my-local-lib-0.1.0-py3-none-any.whl
d
The bleeding edge decorators support this (or should). Not sure about stock ones though.
b
Thanks! I was unsure of the precise syntax for getting load of requirements.txt files accomplished
d
You can use metaflow environment resolve to resolve a regular requirements.txt and give the environment a name or you can just use the decorators. Both should work. Let me know what your requirements are and I can give you both syntaxes.
b
Yes, so suppose I had a
my-local-lib-0.1.0-py3-none-any.whl
file that I wanted to include via decorators & that I've loaded bleeding edge. What syntax would you suggest?
d
something like:
@pypi(packages={"/root/flows/conda_tests/my-local-lib-0.1.0-py3-none-any.whl": ""})
should work (just tried it on a trivial example)
if you specify a directory where the package is (unbuilt), it should also work and build it for you.
b
Beautiful