Skip to content

Commit

Permalink
Merge pull request #369 from oist/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ShogoAkiyama authored Jun 24, 2022
2 parents 3c6cf38 + 1ac2c08 commit bfef6df
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ __pycache__
.vscode/*
!.vscode/settings.json
dist
./build
/build
optinist/frontend

optinist.extensions.yaml
optinist.namespace.yaml
Expand Down
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ RUN apt-get --allow-releaseinfo-change update && \
apt-get install --no-install-recommends -y git gcc g++ libgl1 libgl1-mesa-dev && \
pip3 install --no-cache-dir --upgrade pip && \
pip3 install --no-cache-dir -r /app/requirements.txt && \
pip3 install --no-cache-dir cython==0.29.30 && \
pip3 install --no-cache-dir \
cython==0.29.30 \
holoviews==1.14.9 \
ipyparallel==8.4.1 \
matplotlib==3.5.2 \
opencv-python==4.6.0.66 \
scikit-image==0.18.0 \
scikit-learn==1.1.1 \
tensorflow==2.9.1 && \
watershed==2.2.2 \
pip3 install --no-cache-dir git+https://github.com/flatironinstitute/CaImAn.git@914324989443fac5d481ef32aad4f327701294a8#egg=caiman && \
apt-get purge git -y && apt-get autoremove -y && apt-get clean && rm -rf /root/.cache/pip/*

Expand All @@ -28,4 +37,6 @@ COPY main.py /app/main.py
ENV PATH $PATH:/root/miniconda3/bin
WORKDIR /app
EXPOSE 8000
ENTRYPOINT ["python3", "main.py"]

ENTRYPOINT ["python3", "main.py"]
CMD ["--host", "0.0.0.0"]
21 changes: 10 additions & 11 deletions Dockerfile-test
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM python:3.9.7
FROM python:3.9.7-slim

RUN mkdir /app
WORKDIR /app

RUN apt-get --allow-releaseinfo-change update
RUN apt-get install -y git gcc g++ libgl1
COPY requirements.txt /app/requirements.txt

RUN /usr/local/bin/python -m pip install --upgrade pip
COPY ./requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install pytest
RUN apt-get --allow-releaseinfo-change update && \
apt-get install --no-install-recommends -y git gcc g++ libgl1 && \
pip3 install --no-cache-dir --upgrade pip && \
pip3 install --no-cache-dir -r /app/requirements.txt && \
pip3 install --no-cache-dir pytest && \
apt-get purge git -y && apt-get autoremove -y && apt-get clean && rm -rf /root/.cache/pip/*

ENTRYPOINT ["python", "-m", "pytest", "-s", "."]
WORKDIR /app
ENTRYPOINT ["python3", "-m", "pytest", "-s", "."]
16 changes: 11 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from fastapi.templating import Jinja2Templates

import os
import argparse
import uvicorn
from starlette.middleware.cors import CORSMiddleware
DIRPATH = os.path.dirname(os.path.abspath(__file__))
from optinist.routers import (
files,
run,
Expand All @@ -16,6 +16,8 @@
experiment,
)

DIRPATH = os.path.dirname(os.path.abspath(__file__))

app = FastAPI(docs_url="/docs", openapi_url="/openapi")
app.include_router(algolist.router)
app.include_router(files.router)
Expand All @@ -30,25 +32,29 @@
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"]
allow_headers=["*"],
)

app.mount(
"/static",
StaticFiles(directory=f"{DIRPATH}/frontend/build/static"),
name="static"
name="static",
)

templates = Jinja2Templates(directory=f"{DIRPATH}/frontend/build")


@app.get("/")
async def root(request: Request):
return templates.TemplateResponse("index.html", {"request": request})


def main():
uvicorn.run('main:app', port=8000, reload=True)
parser = argparse.ArgumentParser()
parser.add_argument("--host", type=str, default="127.0.0.1")
args = parser.parse_args()
uvicorn.run("main:app", host=args.host, port=8000, reload=True)


if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion optinist/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_MINOR = "1"
# On main and in a nightly release the patch should be one ahead of the last
# released build.
_PATCH = "0"
_PATCH = "1"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = ""
Expand Down
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from setuptools import setup, find_packages, Extension
import os
from setuptools import setup, find_packages

here = os.path.abspath(os.path.dirname(__file__))
exec(open(os.path.join(here, 'optinist', 'version.py')).read())

def _requires_from_file(filepath):

def take_package_name(name):
if name.startswith("git+"):
_package = name.strip("=")[-1]
return f"{_package}"
if "snakemake" in name:
return f"snakemake @ https://github.com/ShogoAkiyama/snakemake/archive/refs/tags/v7.7.2-post1.zip"
else:
return name.strip()

Expand All @@ -14,7 +17,7 @@ def take_package_name(name):

setup(
name="optinist",
version="0.1.0-6",
version=VERSION,
description="An offline deep reinforcement learning library",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
Expand All @@ -34,7 +37,6 @@ def take_package_name(name):
"Operating System :: MacOS :: MacOS X"
],
install_requires=_requires_from_file('requirements.txt'),
dependency_links=["git+https://github.com/ShogoAkiyama/snakemake@main#egg=snakemake"],
packages=find_packages(exclude=["optinist/tests*"]),
tests_require=["pytest"],
zip_safe=False,
Expand Down

0 comments on commit bfef6df

Please sign in to comment.