Skip to content

Commit

Permalink
Merge pull request #1 from vivarium-collective/process-setup
Browse files Browse the repository at this point in the history
feat: added deps to requirements and configured setup file
  • Loading branch information
AlexPatrie authored Jul 24, 2023
2 parents d03d24e + ef75b7a commit ad6daa4
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 134 deletions.
Binary file added .DS_Store
Binary file not shown.
28 changes: 14 additions & 14 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ on:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.10']
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; else pip install -e .; fi
- name: Test with pytest
run: |
pytest -v
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.egg
*.egg-info
/idea
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
python_files = *.py
addopts = --doctest-modules --strict-markers
# TODO: Replace `template` when you change the folder name.
testpaths = template
testpaths = vivarium_tellurium
markers =
slow: indicates slow tests (deselect with '-m "not slow"')
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
# pip install -r requirements.txt
#

-e .
vivarium-core
tellurium
pytest
37 changes: 16 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
import os
import glob
import setuptools
from distutils.core import setup
# import os
from setuptools import setup

with open("README.md", 'r') as readme:
long_description = readme.read()

setup(
name='', # TODO: Put your package name here.
name='vivarium-tellurium',
version='0.0.1',
packages=[
# TODO: Replace 'template' with the name of your folder.
'template',
'template.processes',
'template.composites',
'template.experiments',
'vivarium_tellurium',
'vivarium_tellurium.composites',
'vivarium_tellurium.experiments',
'vivarium_tellurium.library',
'vivarium_tellurium.processes',
],
author='', # TODO: Put your name here.
author_email='', # TODO: Put your email here.
url='', # TODO: Put your project URL here.
license='', # TODO: Choose a license.
entry_points={
'console_scripts': []},
short_description='', # TODO: Describe your project briefely.
author='Eran Agmon, Alexander Patrie',
author_email='',
url='https://github.com/vivarium-collective/vivarium-tellurium',
license='',
description='A Vivarium interface for Tellurium',
long_description=long_description,
long_description_content_type='text/markdown',
package_data={},
include_package_data=True,
install_requires=[
'vivarium-core>=1.0.0',
'vivarium-core',
'tellurium',
'pytest',
# TODO: Add other dependencies.
],
)
)
Binary file added vivarium_tellurium/.DS_Store
Binary file not shown.
55 changes: 0 additions & 55 deletions vivarium_tellurium/composites/injected_glc_phosphorylation.py

This file was deleted.

113 changes: 113 additions & 0 deletions vivarium_tellurium/composites/template_composite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
"""
==================
Template Composite
==================
This is a toy composite that loads in two template processes and combines them.
"""

# TODO: Delete this file before publishing your project.

from vivarium.core.engine import Engine, pp
from vivarium.core.composer import Composer
from vivarium.library.pretty import format_dict
from vivarium.processes.injector import Injector

from vivarium_tellurium.processes.tellurium_process import Template


class TemplateComposer(Composer):

defaults = {
'template1': {
'parameter1': 2.0,
},
'template2': {
'parameter1': 5.0,
},
}

def __init__(self, config=None):
super().__init__(config)

def generate_processes(self, config):
template1 = Template(self.config['template1'])
template2 = Template(self.config['template2'])

return {
'template1': template1,
'template2': template2,
}

def generate_topology(self, config):
return {
'template1': {
'internal': ('internal_1',),
'external': ('external_shared', ),
},
'template2': {
'internal': ('internal_2',),
'external': ('external_shared', ),
},
}


def test_template_composite():
'''Run a simulation of the composite.
Returns:
The simulation output.
'''

# 1.) Declare the initial state, mirroring the ports structure. May be passed as a parsable argument.
initial_state = {
'internal_1': {
'A': 0.0
},
'internal_2': {
'A': 10.0
},
'external_shared': {
'A': 1.0
},
}

# 2.) Create the simulation run parameters for the simulator
config = {
'template1': {
'parameter1': 4.0,
},
'template2': {
'parameter1': 4.0,
}
}

# 3.) Initialize the composer by passing in a config dict
template_composer = TemplateComposer(config)

# 4.) Generate a composite by calling the Composers' generate method
template_composite = template_composer.generate()

# 5.) Feed the compsite instance you just created to the vivarium Engine
sim = Engine(
composite=template_composite,
initial_state=initial_state
)

# 6.) Call update with that sim object, which calls the next_update method in the implementation you created above using total_time
total_time = 3
sim.update(
interval=total_time
)

# 7.) Get the data which is emitted from the sim object.
data = sim.emitter.get_timeseries()

# 7a.) Observe the data which is return from running the process:
print(f'RESULTS: {pp(data)}')
return data


# run module with python template/processes/template_composite.py
if __name__ == '__main__':
test_template_composite()
Loading

0 comments on commit ad6daa4

Please sign in to comment.