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

easy installation through pip #38

Merged
merged 19 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
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
63 changes: 63 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish PyPI

on:
release:
types: [published]


jobs:
build:

runs-on: ${{ matrix.os-version }}
name: ${{ matrix.os-version }} (${{ matrix.python-version }})

strategy:
fail-fast: false
matrix:
os-version: ["ubuntu-latest"]
python-version: ["3.9"] # ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: "Install flake8"
run: |
pip install flake8
- name: "Lint with flake8"
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: "Install miniconda"
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
mamba-version: "*"
python-version: ${{ matrix.python-version }}
channels: conda-forge,bioconda
environment-file: environment.yml
- name: "Install pytest"
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build pytest
pip install twine
- name: "Test with pytest"
shell: bash -l {0}
run: |
pytest -s
- name: Build package
shell: bash -l {0}
run: |
python setup.py bdist_wheel --universal
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
1 change: 1 addition & 0 deletions CanDI/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "0.1.1"
4 changes: 2 additions & 2 deletions CanDI/candi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from CanDI.candi import data
from . import data
data = data.Data() #Global object data instantiated on import required for access by GeneQuery Objects
from CanDI.candi.candi import (Gene, CellLine, Organelle, Cancer, CellLineCluster, GeneCluster)
from . import (Gene, CellLine, Organelle, Cancer, CellLineCluster, GeneCluster)

4 changes: 2 additions & 2 deletions CanDI/candi/candi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import itertools as it
import pandas as pd
import numpy as np
from CanDI.candi import data, grabber
from CanDI.structures import entity
from . import data, grabber
from . import entity

class SubsetHandler(object):

Expand Down
2 changes: 1 addition & 1 deletion CanDI/candi/grabber.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from pathlib import Path
from CanDI.candi import data
from . import data

class Grabber:
""""Grabber class handles all bulk data retrival from the CanDI Classes.
Expand Down
14 changes: 9 additions & 5 deletions CanDI/setup/install.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import argparse
from manager import Manager
from .manager import Manager

if __name__ == "__main__":
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--source", help="Specify the download source", default="dataverse")
parser.add_argument("--data_dir", help="Specify the data directory", default=None)
args = parser.parse_args()

if args.source == 'dataverse':
print("Downloading data from Dataverse")
m = Manager(download_source=args.source)
m = Manager(download_source=args.source, data_dir=args.data_dir)
m.download_reformatted_data()
m.write_config(m.cfig_path, m.parser)

elif args.source == 'depmap':
print("Downloading data from DepMap")
m = Manager(download_source=args.source)
m = Manager(download_source=args.source, data_dir=args.data_dir)
m.get_depmap_info()
m.write_config(m.cfig_path, m.parser)
m.download_defaults()
Expand All @@ -23,4 +24,7 @@
m.write_config(m.cfig_path, m.parser)

else:
raise ValueError("Invalid source. Please specify either 'dataverse' or 'depmap'")
raise ValueError("Invalid source. Please specify either 'dataverse' or 'depmap'")

if __name__ == "__main__":
main()
16 changes: 13 additions & 3 deletions CanDI/setup/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
from time import sleep
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor
from dataverse import depmap_dataverse_download
from .dataverse import depmap_dataverse_download

class Manager(object):
"""The Manager class handles interations with the datasources
and the config file. It is used to setup of the config file upon installation.
All data downloading is done by Manager
"""
def __init__(self, download_source=None):
def __init__(self, download_source=None, data_dir=None):

manager_path = os.path.dirname(os.path.realpath(__file__))
if data_dir:
manager_path = data_dir
else:
manager_path = os.path.dirname(os.path.realpath(__file__))

cfig_path = manager_path + "/data/config.ini"
parser = configparser.ConfigParser()
parser.read(cfig_path.replace(".ini", ".draft.ini"))
Expand Down Expand Up @@ -218,6 +222,12 @@ def format_depmap_data(self, df, path):


def download_reformatted_data(self, depmap_release=''):
if not os.path.exists(self.manager_path + '/data/'):
os.makedirs(self.manager_path + '/data/')

if not os.path.exists(self.manager_path + '/data/depmap/'):
os.makedirs(self.manager_path + '/data/depmap/')

if self.download_source == "dataverse":
urls, file_names = depmap_dataverse_download(
self.manager_path + '/data/depmap/',
Expand Down
2 changes: 1 addition & 1 deletion CanDI/setup/reset_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import configparser
import json
from manager import Manager
from .manager import Manager


def main():
Expand Down
2 changes: 1 addition & 1 deletion CanDI/structures/entity.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pandas as pd
from CanDI.structures import handlers
from . import handlers

class Entity(object):

Expand Down
25 changes: 6 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ CanDI - A global cancer data integrator
Package Installation
--------------------

First, you need to clone this repository to use CanDI.
CanDI is now available on `PyPI <https://pypi.org/project/CanDI/>`_ and can be installed with pip:

.. code:: bash

git clone https://github.com/GilbertLabUCSF/CanDI.git
pip install CanDI

We suggest to use `Conda <https://docs.conda.io/en/latest/>`__ as a
package manager and environment management system. You can create a
fresh conda environment with all ``CanDI``\ ’s requirements using bellow
command:
___
For the latest version (development version) install from GitHub:

.. code:: bash

pip install git+https://github.com/GilbertLabUCSF/CanDI.git

conda env create -f CanDI/environment.yml -n candi

Prepare Datasets
~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -59,22 +58,10 @@ Package Usage
Import CanDI into python
~~~~~~~~~~~~~~~~~~~~~~~~

To import ``CanDI``, your active directory in python must be same as the
cloned folder.

.. code:: python

from CanDI import candi

**OR**, you can add path to the `CanDI` directory if you want to use it from other directories.

.. code:: python

import sys
sys.path.append("path-to-candi-directory")

from CanDI import candi

CanDI Objects
~~~~~~~~~~~~~

Expand Down
31 changes: 31 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from setuptools import setup, find_packages
from CanDI.__version__ import version

from pathlib import Path

this_directory = Path(__file__).parent

setup(
name='CanDI',
description='A cancer data integration package',
version=version,
packages=find_packages(),
python_requires='>=3.9',
install_requires=[
"pandas",
"configparser",
"requests",
"tqdm",
],
url = 'https://github.com/GilbertLabUCSF/CanDI',
entry_points={
'console_scripts': [
'candi-install = CanDI.setup.install:main',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

candi-install works as a command.

usage: candi-install [-h] [--source SOURCE] [--data_dir DATA_DIR]

optional arguments:
  -h, --help           show this help message and exit
  --source SOURCE      Specify the download source
  --data_dir DATA_DIR  Specify the data directory

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Yogiski – Hi Chris, hope all is well! I made some changes to CanDI. Let me know what you think!

],
},
classifiers=[
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
],
)
Loading