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

Make SPRAS installable #126

Merged
merged 7 commits into from
Oct 13, 2023
Merged

Conversation

jhiemstrawisc
Copy link
Collaborator

@jhiemstrawisc jhiemstrawisc commented Sep 12, 2023

This commit adds the ability to install spras as a python module using pip, which is something we'll need for running in remote environments such as on the OSPool. The installation "instructions" used by pip during building are laid out in pyproject.toml. While I chose to use setup-tools as a builder backend in this first pass, other builder backends with more robust build features are available and may eventually be switched to (eg flit, poetry).

Several additional files had to be modified to adhere to python packaging guidelines, the most notable of which was changing src to spras, and referencing the new spras directory instead of src. Several lines of omicsintegrator2.py were also modified becasue they were dealing with an absolute path, which made the workflow un-runnable outside of the repo. I verified that all tests and the entirety of the snakefile still run both in the conda environment from the repo root (which is how the tool is currently used) and in a separate directory with spras installed where the input data, snakefile, and config file have been brought along.

For testing, install spras using pip install . in the repo root. If the extra development packages are needed, spras can be installed with the command pip install .[dev]. Spras can also be installed via pip install -e . to make the installation editable. That is, when installed via this command, you can continue to edit spras in the repo and have those changes reflected anywhere you run spras on the machine.

Note that several package versions had to be modified (they're noted in pyproject.toml) to get past a few versioning issues between conda and pypi. To the extent of my knowledge and testing, these changes didn't affect the way spras runs. Famous last words?

If this passes tests and is merged, it closes #86.

@jhiemstrawisc
Copy link
Collaborator Author

jhiemstrawisc commented Sep 12, 2023

P.S. I only added Tony in the pyproject.toml authors because I wasn't sure who else to reference here. Feel free to adjust as necessary! I also left the version of spras pinned as v0.0.1 because I wasn't sure how to determine what version spras is currently on.

Copy link
Collaborator

@agitter agitter left a comment

Choose a reason for hiding this comment

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

I reviewed https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#declaring-project-metadata and made suggestions for the metadata. We should let @annaritz comment as well.

Do we want to comment on installing with pip either in the main readme or in the contributing guide for developers?

Everything else looks good to me.

pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
This commit adds the ability to install spras as a python module using pip,
which is something we'll need for running in remote environments such as on
the OSPool. The installation "instructions" used by pip during building are
laid out in `pyproject.toml`. While I chose to use setup-tools as a builder
backend in this first pass, other builder backends with more robust build
features are available and may eventually be switched to (eg flit, poetry).

Several additional files had to be modified to adhere to python packaging
guidelines, the most notable of which was changing `src` to spras, and referencing
the new spras directory instead of src. Several lines of omicsintegrator2.py were
also modified becasue they were dealing with an absolute path, which made the
workflow un-runnable outside of the repo. I verified that all tests and the entirety of
the snakefile still run both in the conda environment from the repo root (which is
how the tool is currently used) and in a separate directory with spras installed where
the input data, snakefile, and config file have been brought along.

For testing, install spras using `pip install .` in the repo root. If the extra
development packages are needed, spras can be installed with the command
`pip install .[dev]`. Spras can also be installed via `pip install -e .` to
make the installation editable. That is, when installed via this command, you
can continue to edit spras in the repo and have those changes reflected anywhere
you run spras on the machine.

Note that several package versions had to be modified (they're noted in
pyproject.toml) to get past a few versioning issues between conda and pypi. To the
extent of my knowledge and testing, these changes didn't affect the way spras runs.
Famous last words?
In general, this was just implementing @agitter's suggested changes. One of the questions
that was raised was why I unpinned the version of docutils. I had to double check, but it
looks like pinning the version caused a compatibility issue, specifically with the pip-
installed package `sphinx-rtd-theme`. Rather than unpinning Docutils or bumping it down by
a version, I bumped `sphinx-rtd-theme` up two versions (in both `environment.yaml` and
the `pyproject.toml`) to satisfy the dependency conflict. The change appears not to have
caused issues, but I'm also not aware of how the doc-building mechanism works, so I'm
not sure how to give it a more robust test.
@annaritz
Copy link
Contributor

annaritz commented Oct 4, 2023

pyproject.toml authors and emails look good to me.

Copy link
Collaborator

@agitter agitter left a comment

Choose a reason for hiding this comment

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

I tested the installation locally

$ conda create -n spras-new python=3.8
$ conda activate spras-new
$ python -m pip install -e .[dev] .

This failed with

...
Collecting semver>=2.8.1 (from spython==0.2->spras==0.0.1)
  Obtaining dependency information for semver>=2.8.1 from https://files.pythonhosted.org/packages/9a/77/0cc7a8a3bc7e53d07e8f47f147b92b0960e902b8254859f4aee5c4d7866b/semver-3.0.2-py3-none-any.whl.metadata
  Downloading semver-3.0.2-py3-none-any.whl.metadata (5.0 kB)
INFO: pip is looking at multiple versions of spras[dev] to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install spras 0.0.1 (from \spras) and spras[dev]==0.0.1 because these package versions have conflicting dependencies.
The conflict is caused by:
    The user requested spras 0.0.1 (from \spras)
    spras[dev] 0.0.1 depends on spras 0.0.1 (from \spras)
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

It looks like the command tries to install the dev and non-dev versions. Using

$ python -m pip install -e .[dev]

succeeded. If you agree that is the correct command, can you please update the documentation accordingly?

I checked the machine learning figures and Cytoscape session produced by the default Snakemake workflow, and everything still looks good.

README.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@agitter agitter merged commit 1cc6acb into Reed-CompBio:master Oct 13, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create installable Python package
3 participants