Skip to content

Commit

Permalink
Add fhirpathpy as dependency (#62)
Browse files Browse the repository at this point in the history
* Add fhirpathpy as dependency

* Fix workflow to not install fhirpathpy
  • Loading branch information
giuliabaldini authored Jul 1, 2022
1 parent f4d79c6 commit 1f156b2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 53 deletions.
1 change: 0 additions & 1 deletion .github/workflows/mypy-flake-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
export PATH="/root/.local/bin:$PATH"
poetry run pip install -U pip
poetry install -E all
pip install git+https://github.com/beda-software/fhirpath-py.git
- name: Run MyPy
run: |
poetry run mypy --install-types --non-interactive fhir_pyrate/
Expand Down
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ pip install "fhir-pyrate[downloader]" # only for downloader
pip install "fhir-pyrate[all]" # for both
```

If you want to use the FHIRPath capabilities you also need to
install [fhirpath-py](https://github.com/beda-software/fhirpath-py) with
```bash
pip install git+https://github.com/beda-software/fhirpath-py.git
```

### Or Within Poetry
We can also use poetry for this same purpose. Using PyPi we need to run the following commands.
```bash
Expand Down Expand Up @@ -122,11 +116,6 @@ or by adding the following to your `pyproject.toml` file:
fhir-pyrate = {git = "https://github.com/UMEssen/FHIR-PYrate.git", branch = "main", extras = ["all"]}
```

And if you want to use FHIRPaths, add [fhirpath-py](https://github.com/beda-software/fhirpath-py).
```bash
poetry add git+https://github.com/beda-software/fhirpath-py.git
```

## Run Tests

When implementing new features, make sure that the existing ones have not been broken by using our
Expand Down Expand Up @@ -364,13 +353,6 @@ df = search.bundles_to_dataframe(
fhir_paths=["id", ("code", "code.coding"), ("identifier", "identifier[0].code")],
)
```
**NOTE on [fhirpath-py](https://github.com/beda-software/fhirpath-py)**: This package is
currently not on PyPi and
[PyPi does not allow packages that are not on PyPi](https://github.com/pypa/pip/issues/6301),
so if you want to use this feature you need to install the package separately or use:
```
pip install git+https://github.com/UMEssen/FHIR-PYrate.git
```
**NOTE 1 on FHIR paths**: The standard also allows some primitive math operations such as modulus
(`mod`) or integer division (`div`), and this may be problematic if there are fields of the
resource that use these terms as attributes.
Expand Down
22 changes: 1 addition & 21 deletions fhir_pyrate/pirate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pandas as pd
import requests
from dateutil.parser import parse
from fhirpathpy import compile
from tqdm import tqdm

from fhir_pyrate import Ahoy
Expand Down Expand Up @@ -52,13 +53,6 @@ class Pirate:
"xor",
"implies",
]
FHIRPATH_IMPORT_ERROR = (
"The fhirpath-py package cannot be pushed as a package dependency because it is not "
"present on PyPi, if you want to use the FHIRPath functionalities you need to install "
"this package using "
"`pip install git+https://github.com/beda-software/fhirpath-py.git` or by adding it to "
"poetry."
)

def __init__(
self,
Expand Down Expand Up @@ -641,10 +635,6 @@ class whenever the creation of a DataFrame happens directly after the query
```
"""
if fhir_paths is not None:
try:
from fhirpathpy import compile
except ImportError as e:
raise ImportError(self.FHIRPATH_IMPORT_ERROR) from e
logger.debug(
f"The selected process_function {process_function.__name__} will be "
f"overwritten."
Expand Down Expand Up @@ -748,11 +738,6 @@ def trade_rows_for_dataframe(
:return: A pandas DataFrame containing the queried information merged with the original
DataFrame
"""
if fhir_paths is not None:
try:
import fhirpathpy # noqa
except ImportError as e:
raise ImportError(self.FHIRPATH_IMPORT_ERROR) from e
request_params = {} if request_params is None else request_params
logger.info(
f"Querying each row of the DataFrame with {self.num_processes} processes."
Expand Down Expand Up @@ -850,11 +835,6 @@ class whenever the creation of a DataFrame happens directly after the query
please refer to the documentation of the respective methods.
:return: A pandas DataFrame containing the queried information
"""
if fhir_paths is not None:
try:
import fhirpathpy # noqa
except ImportError as e:
raise ImportError(self.FHIRPATH_IMPORT_ERROR) from e
return self.bundles_to_dataframe(
bundles=bundles_function(**kwargs),
process_function=process_function,
Expand Down
19 changes: 7 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pandas = "^1.3.0"
tqdm = "^4.56.0"
requests = "^2.28.0"
PyJWT = "^2.4.0"
fhirpathpy = "^0.1.0"


[tool.poetry.extras]
Expand All @@ -36,7 +37,6 @@ all = ["SimpleITK", "pydicom", "dicomweb-client", "spacy"]

[tool.poetry.dev-dependencies]
python-dotenv = "^0.20.0"
fhirpathpy = {git = "https://github.com/beda-software/fhirpath-py.git"}
pre-commit = "^2.14.0"
flake8 = "3.9.2"
mypy = "0.910"
Expand Down

0 comments on commit 1f156b2

Please sign in to comment.