Skip to content
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

Add cmdstan #15203

Merged
merged 52 commits into from Aug 9, 2021
Merged

Add cmdstan #15203

merged 52 commits into from Aug 9, 2021

Conversation

maresb
Copy link
Contributor

@maresb maresb commented Jun 6, 2021

Checklist

  • Title of this PR is meaningful: e.g. "Adding my_nifty_package", not "updated meta.yaml".
  • License file is packaged (see here for an example).
  • Source is from official source.
  • Package does not vendor other packages. (If a package uses the source of another package, they should be separate packages or the licenses of all packages need to be packaged).
  • If static libraries are linked in, the license of the static library is packaged.
  • Build number is 0.
  • A tarball (url) rather than a repo (e.g. git_url) is used in your recipe (see here for more details).
  • GitHub users listed in the maintainer section have posted a comment confirming they are willing to be listed there.
  • When in trouble, please check our knowledge base documentation before pinging a team.

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found it was in an excellent condition.

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found some lint.

Here's what I've got...

For recipes/cmdstan:

  • Selectors are suggested to take a <two spaces>#<one space>[<expression>] form. See lines [38, 39, 40, 41]

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found it was in an excellent condition.

@wolfv
Copy link
Member

wolfv commented Jul 9, 2021

@maresb it looks like tbbmalloc_proxy is compiled, but not installed?

x86_64-apple-darwin13.4.0-clang -fPIC -o libtbbmalloc.dylib backend.o large_objects.o backref.o  tbbmalloc.o  itt_notify_malloc.o frontend.o  -ldl -lpthread -dynamiclib -install_name @rpath/libtbbmalloc.dylib -stdlib=libc++ -m64 -L/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/system -L/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/ -mmacosx-version-min=10.9 -Wl,-L,"$SRC_DIR/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"$SRC_DIR/stan/lib/stan_math/lib/tbb"   -Wl,-exported_symbols_list,tbbmalloc.def
x86_64-apple-darwin13.4.0-clang++ -fPIC -o libtbbmalloc_proxy.dylib proxy.o tbb_function_replacement.o  -ldl -lpthread libtbbmalloc.dylib -dynamiclib -install_name @rpath/libtbbmalloc_proxy.dylib -stdlib=libc++ -m64 -L/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/system -L/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/ -mmacosx-version-min=10.9 -Wl,-L,"$SRC_DIR/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"$SRC_DIR/stan/lib/stan_math/lib/tbb"  

which then results in an overlinking warning

@wolfv
Copy link
Member

wolfv commented Jul 12, 2021

Can you check that the file is installed properly (copied into the prefix?)

@WardBrian
Copy link
Contributor

Should it be copied into $prefix/lib? With the file structure or without?

Additionally, do you know why the OSX and Win tests seem to be taking orders of magnitude longer than the linux test? I've been unable to run anything other than the linux test locally, so I'm relying on the CI build

@wolfv
Copy link
Member

wolfv commented Jul 12, 2021

If you link against it, you should install it (otherwise it's gonna be missing at execution time )

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found some lint.

Here's what I've got...

For recipes/cmdstan:

  • The "test" section was expected to be a dictionary, but got a NoneType.
  • There are too few lines. There should be one empty line at the end of the file.
  • The "test" section was expected to be a dictionary, but got a NoneType.

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found it was in an excellent condition.


make clean-all

ls $PREFIX/lib
TBB_LIB=$PREFIX/lib make -j8 build
make build -j4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to use -j${CPU_COUNT}

@maresb
Copy link
Contributor Author

maresb commented Jul 26, 2021

Hi @WardBrian, sorry for the delay. I'm on the road so it's tough for me to give anything more than a reactionary response.

These C++ packages are really beyond my realm of expertise so take whatever I say with a grain of salt.

The license issues are indeed unfortunate, and I'm not so sure what to do about that.

Licenses aside, I think the big potential problems would be if those libraries would somehow lead to conflicts by overwriting existing libraries. Having a quick look at the artifacts, I see that tbb.dll is included in the bin/ directory on Windows. Could this be problematic?

@wolfv and/or @conda-forge/help-c-cpp, any suggestions?

@WardBrian
Copy link
Contributor

WardBrian commented Jul 27, 2021

My understanding of Windows linking issues means the tbb.dll could be a problem for other users. Luckily, tbb just released a new and not-backwards-compatible version which I believe uses a different filename for it's library files, so I think we could set it up so that you cannot install earlier tbbs (that would conflict with this one?). That's an open question I have for those more experienced. Nothing besides TBB ends up in the PATH, so I don't think there are any concerns besides that one

@WardBrian
Copy link
Contributor

Re: the license issues - every included package is used within its license and has said license included with it in the subfolder (mainly in stan/lib/stan_math/lib) so I don't think it is a problem per se, we just may need to indicate this somehow in the metadata, and that's what I'm unsure about.

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found some lint.

Here's what I've got...

For recipes/cmdstan:

  • The requirements section contained an unexpected subsection name. run-constrained is not a valid subsection name.

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found it was in an excellent condition.

@WardBrian
Copy link
Contributor

@conda-forge-admin, please ping team

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-webservice.

I was asked to ping @conda-forge/staged-recipes and so here I am doing that.

Comment on lines 28 to 29
- {{ compiler('cxx') }} # [not win]
- make # [not win]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this in run?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CmdStan is sort of an odd duck - it is a tool for compiling models in the stan language, so it's one part library and one part build script. The actual usage of the tool at runtime requires Make and a c++ toolchain. The docs go into more detail, if you're curious, but essentially a .stan program is translated into a cpp file, which is then linked with the stan library and compiled to be run. CmdStan handles the first half of this, and provides a build script for the last portion, but it assumes you have a compiler to do so

build:
- {{ compiler('cxx') }} # [not win]
- make # [not win]
- tbb-devel =2020.2 # [not win]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- tbb-devel =2020.2 # [not win]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBB has been an issue for us, so we ended up doing a sort of two-pronged approach: On Unix and MacOS, we depend on the conda-shipped TBB to make compilation simpler. On Windows, due to our dependence on mingw64's gcc, we have to compile our own tbb, hence this line.

We tried more or less every other combination in the above commits, but sadly this is what we found was required. The heavy use of templating in Stan's c++ code does not work under MSVC, so we need to take this somewhat odd route on Windows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think you just meant that this library is in both build and host. My bad, I believe that is unintentional. The above comment can just serve as historical record, then.

- {{ compiler('cxx') }} # [not win]
- make # [not win]
- tbb-devel =2020.2 # [not win]
- m2w64-toolchain # [win]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use {{ compiler("m2w64_cxx") }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found some lint.

Here's what I've got...

For recipes/cmdstan:

  • Selectors are suggested to take a <two spaces>#<one space>[<expression>] form. See lines [20, 31]

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipes/cmdstan) and found it was in an excellent condition.

@WardBrian
Copy link
Contributor

Thank you for the comments @isuruf! We would appreciate any more review you could offer, or approval if it all looks good

chmod +x "${PREFIX}/bin/cmdstan_model"

# activate script
echo "export CMDSTAN=${PREFIX}/bin/cmdstan" > "${RECIPE_DIR}/activate.sh"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Activate script should backup any existing CMDSTAN variable and deactivate should restore the backup. Btw, why is CMDSTAN needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMDSTAN is used by the Python and R bindings (‘CmdStanPy’ and ‘CmdStanR’) to find CmdStan if it is not installed in the users home directory. We set it here so that this package is plug and play with those bindings, which we believe will be the majority of the install base based on current usage

I will make the change to set a temporary and restore it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMDSTAN is now stored to CMDSTAN_OLD by activate, and restored to that value in deactivate

@WardBrian
Copy link
Contributor

@wolfv or @isuruf we'd really appreciate if you took another look at this for review or merging. Thank you again for all your help so far!

- m2-sed # [win]
- m2-coreutils # [win]
host:
- tbb-devel =2020.2 # [not win]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use the global pining

Suggested change
- tbb-devel =2020.2 # [not win]
- tbb-devel # [not win]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the global pinning ever change? CmdStan can be compiled with more recent versions of TBB but it requires extra flags set in the make command

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll get a PR to cmdstan-feedstock when it changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I've removed the pinning. Thanks for all the review! Happy to address anything else that stands out still

run:
- {{ compiler('cxx') }} # [not win]
- make # [not win]
- tbb-devel =2020.2 # [not win]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- tbb-devel =2020.2 # [not win]
- tbb-devel # [not win]

Copy link
Member

@isuruf isuruf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Please ping when tests are green

@maresb
Copy link
Contributor Author

maresb commented Aug 9, 2021

@isuruf, thanks for the review, all green!

@wolfv wolfv merged commit e22706d into conda-forge:master Aug 9, 2021
@WardBrian
Copy link
Contributor

Just want to echo, thank you @isuruf and @wolfv!

Copy link
Contributor Author

maresb commented Aug 9, 2021

Thank you @WardBrian, what an amazing effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants