Skip to content

(monarch/tools) extract IN_PAR check as monarch.tools.utils.IN_PAR() util function #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions python/monarch/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
from typing import Optional


def IN_PAR() -> bool:
"""
Returns True if the current process is running in a PAR file. False otherwise.
When this function returns False we typically assume that we are in a Conda env.
"""
try:
from __manifest__ import fbmake # noqa

# since we drop a dummy __manifest__ for monarch_*.whl, __manifest__ exists in both conda and PAR
# so we need to further check the par_style which will be `None` for conda.
return bool(fbmake.get("par_style"))
except ImportError:
return False


class conda:
"""Conda related util functions."""

Expand Down
Loading