generated from FNNDSC/python-chrisapp-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AdaGondova
authored and
AdaGondova
committed
Aug 2, 2024
1 parent
5b90d0a
commit a20f52c
Showing
6 changed files
with
111 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,11 @@ | |
# FROM ghcr.io/mamba-org/micromamba:1.5.1-focal-cuda-11.3.1 | ||
FROM docker.io/python:3.12.1-slim-bookworm | ||
|
||
LABEL org.opencontainers.image.authors="FNNDSC <[email protected]>" \ | ||
org.opencontainers.image.title="ChRIS Plugin Title" \ | ||
org.opencontainers.image.description="A ChRIS plugin that..." | ||
LABEL org.opencontainers.image.authors="FNNDSC <[email protected]>" \ | ||
org.opencontainers.image.title="FETA ChRIS Plugin" \ | ||
org.opencontainers.image.description="code for feta" | ||
|
||
ARG SRCDIR=/usr/local/src/app | ||
ARG SRCDIR=/usr/local/src/FeTA_challenge_2024 | ||
WORKDIR ${SRCDIR} | ||
|
||
COPY requirements.txt . | ||
|
@@ -19,4 +19,4 @@ RUN pip install ".[${extras_require}]" \ | |
&& cd / && rm -rf ${SRCDIR} | ||
WORKDIR / | ||
|
||
CMD ["commandname"] | ||
CMD ["inference"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python | ||
|
||
from pathlib import Path | ||
from argparse import ArgumentParser, Namespace, ArgumentDefaultsHelpFormatter | ||
|
||
from chris_plugin import chris_plugin, PathMapper | ||
|
||
__version__ = '1.0.0' | ||
|
||
DISPLAY_TITLE = r""" | ||
______ _____ ___ _ _ _ _____ _____ _____ ___ | ||
| ___|_ _/ _ \ | | | | | / __ \| _ |/ __ \ / | | ||
| |_ ___| |/ /_\ \ ___| |__ __ _| | | ___ _ __ __ _ ___ `' / /'| |/' |`' / /'/ /| | | ||
| _/ _ \ || _ | / __| '_ \ / _` | | |/ _ \ '_ \ / _` |/ _ \ / / | /| | / / / /_| | | ||
| || __/ || | | || (__| | | | (_| | | | __/ | | | (_| | __/ ./ /___\ |_/ /./ /__\___ | | ||
\_| \___\_/\_| |_/ \___|_| |_|\__,_|_|_|\___|_| |_|\__, |\___| \_____/ \___/ \_____/ |_/ | ||
______ __/ | ______ | ||
|______| |___/ |______| | ||
""" | ||
|
||
|
||
parser = ArgumentParser(description='!!!CHANGE ME!!! An example ChRIS plugin which ' | ||
'counts the number of occurrences of a given ' | ||
'word in text files.', | ||
formatter_class=ArgumentDefaultsHelpFormatter) | ||
parser.add_argument('-w', '--word', required=True, type=str, | ||
help='word to count') | ||
parser.add_argument('-p', '--pattern', default='**/*.txt', type=str, | ||
help='input file filter glob') | ||
parser.add_argument('-V', '--version', action='version', | ||
version=f'%(prog)s {__version__}') | ||
|
||
|
||
# The main function of this *ChRIS* plugin is denoted by this ``@chris_plugin`` "decorator." | ||
# Some metadata about the plugin is specified here. There is more metadata specified in setup.py. | ||
# | ||
# documentation: https://fnndsc.github.io/chris_plugin/chris_plugin.html#chris_plugin | ||
@chris_plugin( | ||
parser=parser, | ||
title='FETA ChRIS Plugin', | ||
category='', # ref. https://chrisstore.co/plugins | ||
min_memory_limit='100Mi', # supported units: Mi, Gi | ||
min_cpu_limit='1000m', # millicores, e.g. "1000m" = 1 CPU core | ||
min_gpu_limit=0 # set min_gpu_limit=1 to enable GPU | ||
) | ||
def main(options: Namespace, inputdir: Path, outputdir: Path): | ||
""" | ||
*ChRIS* plugins usually have two positional arguments: an **input directory** containing | ||
input files and an **output directory** where to write output files. Command-line arguments | ||
are passed to this main method implicitly when ``main()`` is called below without parameters. | ||
:param options: non-positional arguments parsed by the parser given to @chris_plugin | ||
:param inputdir: directory containing (read-only) input files | ||
:param outputdir: directory where to write output files | ||
""" | ||
|
||
print(DISPLAY_TITLE) | ||
|
||
# Typically it's easier to think of programs as operating on individual files | ||
# rather than directories. The helper functions provided by a ``PathMapper`` | ||
# object make it easy to discover input files and write to output files inside | ||
# the given paths. | ||
# | ||
# Refer to the documentation for more options, examples, and advanced uses e.g. | ||
# adding a progress bar and parallelism. | ||
mapper = PathMapper.file_mapper(inputdir, outputdir, glob=options.pattern, suffix='.count.txt') | ||
for input_file, output_file in mapper: | ||
# The code block below is a small and easy example of how to use a ``PathMapper``. | ||
# It is recommended that you put your functionality in a helper function, so that | ||
# it is more legible and can be unit tested. | ||
data = input_file.read_text() | ||
frequency = data.count(options.word) | ||
output_file.write_text(str(frequency)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,18 +19,18 @@ def get_version(rel_path: str) -> str: | |
|
||
|
||
setup( | ||
name='chris-plugin-template', | ||
version=get_version('app.py'), | ||
description='A ChRIS DS plugin template', | ||
name='FeTA_challenge_2024', | ||
version=get_version('inference.py'), | ||
description='code for feta', | ||
author='FNNDSC', | ||
author_email='[email protected]', | ||
url='https://github.com/FNNDSC/python-chrisapp-template', | ||
py_modules=['app'], | ||
author_email='[email protected]', | ||
url='https://github.com/FNNDSC/FeTA_challenge_2024', | ||
py_modules=['inference'], | ||
install_requires=['chris_plugin'], | ||
license='MIT', | ||
entry_points={ | ||
'console_scripts': [ | ||
'commandname = app:main' | ||
'inference = inference:main' | ||
] | ||
}, | ||
classifiers=[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters