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 learna installable via pip #1

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ data-rfam-learn:
requirements:
./thirdparty/miniconda/make_miniconda.sh
conda env create -f environment.yml
@source activate learna && \
pip install .


################################################################################
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ dependencies:
- tqdm
- black
- Distance
- tensorforce==0.3.3
- dataclasses
1 change: 1 addition & 0 deletions learna/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.0.1'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def _download_dataset_from_http(url, download_path):
unit="B",
unit_scale=True,
unit_divisor=1024,
total=int(response.headers["Content-Length"]),
total=int(response.headers["X-ELS-SIZE"]),
)
for data in tqdm(response.iter_content()):
progress_bar.update(len(data))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/learna/design_rna.py → learna/learna/design_rna.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import time

import tensorflow as tf
from ..tensorforce.runner import Runner
from learna.tensorforce.runner import Runner

from .agent import NetworkConfig, get_network, AgentConfig, get_agent_fn
from .environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from learna.learna.agent import NetworkConfig, get_network, AgentConfig, get_agent_fn
from learna.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig


def _get_episode_finished(timeout, stop_once_solved):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Testsuite for RNA-Design environment.
Testsuite for RNA-Design environment.
"""

import pytest
Expand All @@ -9,13 +9,8 @@
from distance import hamming
from itertools import product

from .environment import _string_difference_indices
from .environment import RnaDesignEnvironmentConfig
from .environment import _encode_dot_bracket
from .environment import _encode_pairing
from .environment import _Target
from .environment import _Design
from .environment import RnaDesignEnvironment
from learna.learna.environment import _string_difference_indices, RnaDesignEnvironmentConfig, _encode_dot_bracket, \
_encode_pairing, _Target, _Design, RnaDesignEnvironment

from RNA import fold

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import multiprocessing
from pathlib import Path

from .agent import NetworkConfig, get_network, AgentConfig, ppo_agent_kwargs, get_agent
from .environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from learna.learna.agent import NetworkConfig, get_network, AgentConfig, ppo_agent_kwargs, get_agent
from learna.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig

from ..tensorforce.threaded_runner import clone_worker_agent, ThreadedRunner
from learna.tensorforce.threaded_runner import clone_worker_agent, ThreadedRunner


def episode_finished(stats):
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/optimization/bohb.py → learna/optimization/bohb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import hpbandster.core.result as hpres

from hpbandster.optimizers import BOHB as BOHB
from src.optimization.learna_worker import LearnaWorker
from src.optimization.meta_learna_worker import MetaLearnaWorker
from learna.optimization.learna_worker import LearnaWorker
from learna.optimization.meta_learna_worker import MetaLearnaWorker


parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -66,7 +66,7 @@
parser.add_argument("--mode", choices=["learna", "meta_learna"], default="learna")


# args=parser.parse_args("--run_id test --nic_name lo --shared_directory /tmp --n_cores 4 --data_dir src/data --mode L2DesignRNA".split())
# args=parser.parse_args("--run_id test --nic_name lo --shared_directory /tmp --n_cores 4 --data_dir learna/data --mode L2DesignRNA".split())
args = parser.parse_args()

os.makedirs(args.shared_directory, exist_ok=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from hpbandster.core.worker import Worker


from src.learna.agent import NetworkConfig, get_network, AgentConfig
from src.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from src.learna.design_rna import design_rna
from learna.learna.agent import NetworkConfig, get_network, AgentConfig
from learna.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from learna.learna.design_rna import design_rna


class DesignRNAWorker(Worker):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import ConfigSpace as CS
from hpbandster.core.worker import Worker

from src.learna.agent import NetworkConfig, get_network, AgentConfig
from src.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from src.learna.design_rna import design_rna
from src.learna.learn_to_design_rna import learn_to_design_rna
from learna.learna.agent import NetworkConfig, get_network, AgentConfig
from learna.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from learna.learna.design_rna import design_rna
from learna.learna.learn_to_design_rna import learn_to_design_rna


class L2DesignRNAWorker(Worker):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from hpbandster.core.worker import Worker


from src.learna.agent import NetworkConfig, get_network, AgentConfig
from src.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from src.learna.design_rna import design_rna
from src.data.parse_dot_brackets import parse_dot_brackets
from learna.learna.agent import NetworkConfig, get_network, AgentConfig
from learna.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from learna.learna.design_rna import design_rna
from learna.data.parse_dot_brackets import parse_dot_brackets


class LearnaWorker(Worker):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import ConfigSpace as CS
from hpbandster.core.worker import Worker

from src.learna.agent import NetworkConfig, get_network, AgentConfig
from src.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from src.learna.design_rna import design_rna
from src.learna.learn_to_design_rna import learn_to_design_rna
from src.data.parse_dot_brackets import parse_dot_brackets
from learna.learna.agent import NetworkConfig, get_network, AgentConfig
from learna.learna.environment import RnaDesignEnvironment, RnaDesignEnvironmentConfig
from learna.learna.design_rna import design_rna
from learna.learna.learn_to_design_rna import learn_to_design_rna
from learna.data.parse_dot_brackets import parse_dot_brackets


class MetaLearnaWorker(Worker):
Expand Down
Empty file added learna/tensorforce/__init__.py
Empty file.
File renamed without changes.
46 changes: 46 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- encoding: utf-8 -*-

import setuptools

def read_file(file_name):
with open(file_name, encoding='utf-8') as fh:
text = fh.read()
return text


def get_version(file_name):
with open(file_name, 'r') as fh:
for line in fh.readlines():
if "__version__" in line:
return line.split()[2].replace('\'', '')

setuptools.setup(
name='learna',
author_email='[email protected]',
description='End-to-end RNA Design using deep reinforcement learning',
long_description=read_file('README.md'),
long_description_content_type='text/markdown',
license='Apache-2.0',
url='https://github.com/automl/learna',
project_urls={'Source Code': 'https://github.com/automl/learna'},
version=get_version('learna/__init__.py'),
packages=setuptools.find_packages(exclude=['*.tests', '*.tests.*', 'tests.*', 'tests'],),
python_requires='>=3',
platforms=['Linux'],
classifiers=['Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Development Status :: 4 - Beta',
'Natural Language :: English',
'Environment :: Console',
'Environment :: GPU',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Scientific/Engineering :: Bio-Informatics']
)
2 changes: 1 addition & 1 deletion utils/execution_scripts/LEARNA-10min.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TARGET_STRUCTURE_PATH=$1

source thirdparty/miniconda/miniconda/bin/activate learna
/usr/bin/time -f"%U" python -m src.learna.design_rna \
/usr/bin/time -f"%U" python -m learna.learna.design_rna \
--batch_size 32 \
--conv_channels 8 1 \
--embedding_size 0 \
Expand Down
2 changes: 1 addition & 1 deletion utils/execution_scripts/LEARNA-30min.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TARGET_STRUCTURE_PATH=$1

source thirdparty/miniconda/miniconda/bin/activate learna
/usr/bin/time -f"%U" python -m src.learna.design_rna \
/usr/bin/time -f"%U" python -m learna.learna.design_rna \
--batch_size 79 \
--conv_channels 10 3 \
--embedding_size 0 \
Expand Down
2 changes: 1 addition & 1 deletion utils/execution_scripts/LEARNA.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TARGET_STRUCTURE_PATH=$1

source thirdparty/miniconda/miniconda/bin/activate learna
/usr/bin/time -f"%U" python -m src.learna.design_rna \
/usr/bin/time -f"%U" python -m learna.learna.design_rna \
--mutation_threshold 5 \
--batch_size 126 \
--conv_sizes 17 5 \
Expand Down
2 changes: 1 addition & 1 deletion utils/execution_scripts/Meta-LEARNA-Adapt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TARGET_STRUCTURE_PATH=$1

source thirdparty/miniconda/miniconda/bin/activate learna
/usr/bin/time -f"%U" python -m src.learna.design_rna \
/usr/bin/time -f"%U" python -m learna.learna.design_rna \
--mutation_threshold 5 \
--batch_size 123 \
--conv_sizes 11 3 \
Expand Down
2 changes: 1 addition & 1 deletion utils/execution_scripts/Meta-LEARNA.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TARGET_STRUCTURE_PATH=$1

source thirdparty/miniconda/miniconda/bin/activate learna
/usr/bin/time -f"%U" python -m src.learna.design_rna \
/usr/bin/time -f"%U" python -m learna.learna.design_rna \
--mutation_threshold 5 \
--batch_size 123 \
--conv_sizes 11 3 \
Expand Down