Skip to content

Bulk FHIR Gen 3 Authorization Tagging - #313

Open
dsafarian wants to merge 29 commits into
uc-cdis:masterfrom
dsafarian:fhir_transform
Open

Bulk FHIR Gen 3 Authorization Tagging #313
dsafarian wants to merge 29 commits into
uc-cdis:masterfrom
dsafarian:fhir_transform

Conversation

@dsafarian

Copy link
Copy Markdown

New Features

  • Bulk FHIR Gen 3 Authorization Tagging (see more details with gen3 fhir --help or in the fhir.md in docs/howto)

Dependency updates

  • fhirpathpy

@dsafarian dsafarian changed the title Fhir transform Bulk FHIR Gen 3 Authorization Tagging Aug 19, 2026
Comment thread pyproject.toml Outdated
cdisutilstest = { git = "https://github.com/uc-cdis/cdisutils-test.git", tag = "2.0.0" }
indexd = { git = "https://github.com/uc-cdis/indexd.git", tag = "5.0.4" }
deptry = "^0.23.1"
setuptools = "<82"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this necessary? let's try without it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Pytest version needs to be update to at least 7+
  2. If I don't pin setuptools version, and it installs version 84, I get this error:
    gen3sdk-python/tests/conftest.py'.
    tests/conftest.py:11: in
    from drsclient.client import DrsClient
    ../../../Library/Caches/pypoetry/virtualenvs/gen3-x8jGTXip-py3.13/lib/python3.13/site-packages/drsclient/init.py:1: in
    import pkg_resources
    E ModuleNotFoundError: No module named 'pkg_resources'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and in the original gen3sdk poetry lock there is this, so I think the setuptools verion has to be below 82 in the way it is written now:
[[package]]
name = "setuptools"
version = "80.9.0"
description = "Easily download, build, install, upgrade, and uninstall Python packages"
optional = false
python-versions = ">=3.9"
groups = ["main", "dev"]
files = [
{file = "setuptools-80.9.0-py3-none-any.whl", hash = "sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922"},
{file = "setuptools-80.9.0.tar.gz", hash = "sha256:f36b47402ecde768dbfafc46e8e4207b4360c654f1f3bb84475f0a28628fb19c"},
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try this file (it worked for me):

[tool.poetry]
name = "gen3"
homepage = "https://gen3.org/"
version = "4.29.0"
description = "Gen3 CLI and Python SDK"
authors = ["Center for Translational Data Science at the University of Chicago <support@gen3.org>"]
license = "Apache-2.0"
packages = [
    { include = "gen3" },
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Science/Research",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: Apache Software License",
    "Programming Language :: Python :: 3.9",
    "Topic :: Scientific/Engineering",
]

[tool.poetry.dependencies]
python = ">=3.9, <4"
requests = "*"
indexclient = ">=2.3.0"
drsclient = ">=0.3.0"
aiohttp = "*"
backoff = "*"
cdislogging = ">=1.1.0"
click = "*"
importlib_metadata = ">=8,<9"
jsonschema = "*"
# FIXME updating to >=0.6.0 breaks a few tests
dataclasses-json = "<=0.5.9"
pypfb = ">=0.6.2"
tqdm = ">=4.61.2"
humanfriendly ="*"
python-dateutil = "*"
aiofiles = "*"
pandas = ">=1.4.2"
xmltodict = ">=0.13.0"
gen3users = "*"

# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.
fhirclient = { version = "*", optional = true }
fhirpathpy = { version = "*", optional = true }

[tool.poetry.extras]
fhir = ["fhirclient", "fhirpathpy"]

[tool.poetry.group.dev.dependencies]
pytest = ">=7.0"
pytest-cov = "*"
requests-mock = "*"
cdisutilstest = { git = "https://github.com/uc-cdis/cdisutils-test.git", tag = "2.0.0" }
indexd = { git = "https://github.com/uc-cdis/indexd.git", tag = "5.0.4" }
deptry = ">=0.23.1"

[tool.poetry.scripts]
gen3 = "gen3.cli.__main__:main"

[tool.poetry.plugins."gen3.plugins"]

[build-system]
requires = ["poetry>=1.4.1"]
build-backend = "poetry.masonry.api"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-vv"
testpaths = [
    "tests",
]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked again and this doesnt work...

ImportError while loading conftest 'gen3sdk-python/tests/conftest.py'.
tests/conftest.py:11: in <module>
    from drsclient.client import DrsClient
../../../Library/Caches/pypoetry/virtualenvs/gen3-x8jGTXip-py3.13/lib/python3.13/site-packages/drsclient/__init__.py:1: in <module>
    import pkg_resources
E   ModuleNotFoundError: No module named 'pkg_resources'

Comment thread docs/howto/fhir.md
Comment thread docs/howto/fhir.md
Comment thread gen3/cli/fhir.py Outdated
Comment thread tests/test_data/fhir_config.yaml
Comment thread tests/test_fhir_transform.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
…d functions, included more details in --help
Comment thread gen3/cli/fhir.py Outdated
Comment thread gen3/cli/__main__.py Outdated
Comment thread pyproject.toml Outdated
cdisutilstest = { git = "https://github.com/uc-cdis/cdisutils-test.git", tag = "2.0.0" }
indexd = { git = "https://github.com/uc-cdis/indexd.git", tag = "5.0.4" }
deptry = "^0.23.1"
setuptools = "<82"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try this file (it worked for me):

[tool.poetry]
name = "gen3"
homepage = "https://gen3.org/"
version = "4.29.0"
description = "Gen3 CLI and Python SDK"
authors = ["Center for Translational Data Science at the University of Chicago <support@gen3.org>"]
license = "Apache-2.0"
packages = [
    { include = "gen3" },
]
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Science/Research",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: Apache Software License",
    "Programming Language :: Python :: 3.9",
    "Topic :: Scientific/Engineering",
]

[tool.poetry.dependencies]
python = ">=3.9, <4"
requests = "*"
indexclient = ">=2.3.0"
drsclient = ">=0.3.0"
aiohttp = "*"
backoff = "*"
cdislogging = ">=1.1.0"
click = "*"
importlib_metadata = ">=8,<9"
jsonschema = "*"
# FIXME updating to >=0.6.0 breaks a few tests
dataclasses-json = "<=0.5.9"
pypfb = ">=0.6.2"
tqdm = ">=4.61.2"
humanfriendly ="*"
python-dateutil = "*"
aiofiles = "*"
pandas = ">=1.4.2"
xmltodict = ">=0.13.0"
gen3users = "*"

# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.
fhirclient = { version = "*", optional = true }
fhirpathpy = { version = "*", optional = true }

[tool.poetry.extras]
fhir = ["fhirclient", "fhirpathpy"]

[tool.poetry.group.dev.dependencies]
pytest = ">=7.0"
pytest-cov = "*"
requests-mock = "*"
cdisutilstest = { git = "https://github.com/uc-cdis/cdisutils-test.git", tag = "2.0.0" }
indexd = { git = "https://github.com/uc-cdis/indexd.git", tag = "5.0.4" }
deptry = ">=0.23.1"

[tool.poetry.scripts]
gen3 = "gen3.cli.__main__:main"

[tool.poetry.plugins."gen3.plugins"]

[build-system]
requires = ["poetry>=1.4.1"]
build-backend = "poetry.masonry.api"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-vv"
testpaths = [
    "tests",
]

Comment thread tests/tests/outputs/empty_file Outdated
Comment thread tests/test_fhir_transform.py Outdated
Comment thread tests/test_fhir_transform.py
Comment thread tests/test_fhir_transform.py Outdated
import subprocess
import shutil

TMP_ROOT = pathlib.Path("./tests/test_data/fhir_outputs")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should look into https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html instead of a relative path here, b/c this requires you to run from root to get the outputs in the expected place to .gitignore

The side effect of this is exactly what I think were seeing with the tests/tests/outputs files you accidentally checked in. Those likely used relative paths from wherever the script was run, and you probably ran it with tests/ as the root instead of the repo root at some point.

You don't have to fix it there - but we shouldn't repeat that pattern here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/tests/outputs - these outputs are from the other tests, mine are linked to be within test_data/fhir_output, I forgot to delete the other ones.

I did try to use the pytest tmp_path, the TMP_ROOT is just defining what i want that path to be. Maybe I'm still confused on how to use it:
@pytest.fixture(scope="session") def tmp_root(tmp_path_factory): return tmp_path_factory.mktemp(TMP_ROOT)

I then pass tmp_root to all the tests which require it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we try to do it without the root being specified?

Temporary directories are by default created as sub-directories of the system temporary directory the docs claim this

Comment thread gen3/fhir.py Outdated
Comment thread gen3/fhir.py Outdated
Comment thread gen3/cli/fhir.py Outdated
Comment thread tests/test_data/fhir_config.yaml Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants