Skip to content

Commit 917236e

Browse files
andrewelambBryanFaublejaymedinathomasyu888linglp
authored
[SCHEMATIC-192] V24.12.1 into Main (#1562)
* add new tests * add unit tests * ran black * Update schematic/models/validate_attribute.py Co-authored-by: BryanFauble <17128019+BryanFauble@users.noreply.github.com> * added tests * Update README.md * Update README.md * add unit tests * run black * Update README.md * temp commit * remove old tests * [FDS-2386] Synapse entity tracking and code concurrency updates (#1505) * [FDS-2386] Synapse entity tracking and code concurrency updates * ran black * Update CODEOWNERS * updated data model type rules to include error param * fix validate type attribute to use msg level param * added error handling * run black * create Node class * sat up Node class so that nodes with no displayName fields cause an error on creation * ran black * ran mypy * added new configs for CLI tests * added new manifests for testing CLI commands * automate manual CLI tests * ran black * Update CODEOWNERS * Update scan_repo.yml * Update .github/CODEOWNERS * Update .github/workflows/scan_repo.yml * Attach additional telemetry data to OTEL traces (#1519) * Attach additional telemetry data to OTEL traces * feat: added tracing for cross manifest validation and file name validation (#1509) * add tracing for GX validation * temp commit * Updating contribution doc to expect squash and merge (#1534) * [FDS-2491] Integration tests for Schematic API Test plan (#1512) Integration tests for Schematic API Test plan * [FDS-2500] Add Integration Tests for: Manifest Validation (#1516) * Add Integration Tests for: Manifest Validation * [FDS-2449] Lock `sphinx` version and update `poetry.lock` (#1530) Also install `typing-extensions` in the build * manual test files now being saved in manifests folder * manual test files now being saved in manifests folder * remove lines to delete json files that were under git control * ran black * add try finally blocks to remove created files * ran black * add lines to remove created json files * Update file annotation store process to require filename be present in order to annotate file * add lines to remove created json files * Revert "Update file annotation store process to require filename be present in order to annotate file" This reverts commit f57c718. * Don't attempt to annotate the table * add code in finally blocks to reset config to default values, when tests change them * complete submit manifest command test * ran black * add test for bug case * update test for table tidyness * remove unused import * remove etag column if already present when building temp file view * catch all exceptions to switch to sequential mode * update test for updated data * Revert "update test for updated data" This reverts commit 255e3c0. * Revert "catch all exceptions to switch to sequential mode" This reverts commit 68b0b24. * catch ValueErrors as well * Updates for integration test failures (#1537) * Updates for integration test failures, Config file reset and scope changes * add todos for removing config resets * [FDS-2525] Authenticated export of telemetry data (#1527) * Authenticated export of telemetry data, updating to HTTP otel library * temp reduce tests * restore tests * uncomment tests * redid how files are deleted, manual tests values are set * ran black * [SCHEMATIC-157] Make some dependencies required to avoid `schematic CLI` commands from potentially erroring when doing a pip install (#1540) * Make otel flash non-optional * Add dependencies as non-optional * Include schematic_api for now (#1547) * update toml version to 24.11.1 (#1548) * [SCHEMATIC-193] Support exporting telemetry data from GH integration test runs (#1550) * Support exporting telemetry data from GH run via access token retrieved via oauth2 * [SCHEMATIC-30, SCHEMATIC-200] Add version to click cli / use pathlib.Path module for checking cache size (#1542) * Add version to click cli * Add version * Run black * Reformat * Fix * Update schematic/schemas/data_model_parser.py * Add test for check_synapse_cache_size * Reformat * Fix tests * Remove unused parameter * Install all-extras for now * Make otel flash non-optional * Update dockerfile * Add dependencies as non-optional * Update pyproject toml * Fix trivy issue * Add service version * Run black * Move all utils.general tests into separate folder * Use pre-commit * Add updates to contribution doc * Fix * Add service version to log provider --------- Co-authored-by: BryanFauble <17128019+BryanFauble@users.noreply.github.com> * [SCHEMATIC-212] Prevent traces from being combined (#1552) * Set instance id in github CI run, uninstrument flask auto during integration test run * [SCHEMATIC-163] Catch error when manifest is generated and existing one doesn't have `entityId` (#1551) * adds error handling * adds unit tests for _get_file_entityIds * updates error message * adds entityid check to parent func * updates docstring * [SCHEMATIC-183] Use paths from file view for manifest generation (#1529) source manifest file paths from synapse fileviews at generation * [SCHEMATIC-214] Wrap pandas functions to support not including `None` with the NA values argument (#1553) * Wrap pandas functions to support not including `None` with the NA values argument * Ignore types * pylint issues * ordering of ignore * Add to integration test to cover none in a manifest * Add additional test for manifest * [SCHEMATIC-210] Add attribute to nones data model (#1555) Update example_test_nones.model.csv component and add new invalid manifest with nones * first commit * ran black * add test for validateModelManifest * [SCHEMATIC-214] change data model and component (#1556) * add valid values to Patient attributes * update data model * add test manifests * update test for new model * update test for new valid value * change test to use new manifests * remove uneeded test file * revert file * revert file * change tests to use new manifests * remove uneeded manifests * ran black * add tests back in * ran black * revert manifest * Split up valid and errored test as separate testing functions * Remove unused import --------- Co-authored-by: Gianna Jordan <61707471+GiaJordan@users.noreply.github.com> Co-authored-by: Andrew Lamb <andrewelamb@gmail.com> Co-authored-by: Thomas Yu <thomas.yu@sagebase.org> * incremented packge version number * Update publish.yml * Update test.yml * Update api_test.yml * Update pdoc.yml * Update version.py * updates publish.yml (#1558) (#1561) Co-authored-by: Brad Macdonald <52762200+BWMac@users.noreply.github.com> --------- Co-authored-by: BryanFauble <17128019+BryanFauble@users.noreply.github.com> Co-authored-by: Jenny V Medina <jenny.medina@sagebase.org> Co-authored-by: Thomas Yu <thomas.yu@sagebase.org> Co-authored-by: Lingling <55448354+linglp@users.noreply.github.com> Co-authored-by: GiaJordan <gianna.jordan@sagebase.org> Co-authored-by: Brad Macdonald <52762200+BWMac@users.noreply.github.com> Co-authored-by: Gianna Jordan <61707471+GiaJordan@users.noreply.github.com>
1 parent 816534a commit 917236e

40 files changed

+1255
-460
lines changed

.github/workflows/api_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
test:
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-22.04
1717
env:
1818
POETRY_VERSION: 1.3.0
1919
strategy:

.github/workflows/pdoc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ concurrency:
2525
cancel-in-progress: true
2626
jobs:
2727
build:
28-
runs-on: ubuntu-latest
28+
runs-on: ubuntu-22.04
2929
env:
3030
POETRY_VERSION: 1.3.0
3131
PYTHON_VERSION: "3.10"

.github/workflows/publish.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ on:
77

88
jobs:
99
pypi_release:
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-22.04
1111
env:
1212
POETRY_VERSION: 1.3.0
13+
PYTHON_VERSION: "3.10"
1314
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
1415
steps:
1516
#----------------------------------------------
@@ -18,10 +19,10 @@ jobs:
1819
- name: Check out repository
1920
uses: actions/checkout@v4
2021

21-
- name: Set up Python ${{ matrix.python-version }}
22+
- name: Set up Python ${{ env.PYTHON_VERSION }}
2223
uses: actions/setup-python@v5
2324
with:
24-
python-version: ${{ matrix.python-version }}
25+
python-version: ${{ env.PYTHON_VERSION }}
2526

2627
#----------------------------------------------
2728
# install & configure poetry
@@ -48,7 +49,7 @@ jobs:
4849
- name: Get current pushed tag
4950
run: |
5051
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
51-
echo ${{ env.RELEASE_VERSION }}
52+
echo "$RELEASE_VERSION"
5253
5354
#----------------------------------------------
5455
# override version tag

.github/workflows/scan_repo.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
trivy:
1313
name: Trivy
1414
runs-on: ubuntu-latest
15+
env:
16+
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
17+
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
1518
steps:
1619
- name: Checkout code
1720
uses: actions/checkout@v4

.github/workflows/test.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ concurrency:
2525
cancel-in-progress: true
2626
jobs:
2727
test:
28-
runs-on: ubuntu-latest
28+
runs-on: ubuntu-22.04
2929
env:
3030
POETRY_VERSION: 1.3.0
3131
strategy:
@@ -127,11 +127,31 @@ jobs:
127127
#----------------------------------------------
128128
# run integration test suite
129129
#----------------------------------------------
130+
131+
- name: Retrieve telemetry access token from IDP
132+
if: ${{ contains(fromJSON('["3.10"]'), matrix.python-version) }}
133+
id: retrieve-telemetry-access-token
134+
run: |
135+
response=$(curl --request POST \
136+
--url ${{ vars.TELEMETRY_AUTH_CLIENT_URL }} \
137+
--header 'content-type: application/json' \
138+
--data '{"client_id":"${{ vars.TELEMETRY_AUTH_CLIENT_ID }}","client_secret":"${{ secrets.TELEMETRY_AUTH_CLIENT_SECRET }}","audience":"${{ vars.TELEMETRY_AUTH_AUDIENCE }}","grant_type":"client_credentials"}')
139+
access_token=$(echo $response | jq -r .access_token)
140+
echo "::add-mask::$access_token"
141+
echo "TELEMETRY_ACCESS_TOKEN=$access_token" >> "$GITHUB_OUTPUT"
130142
- name: Run integration tests
131143
if: ${{ contains(fromJSON('["3.10"]'), matrix.python-version) }}
132144
env:
133145
SYNAPSE_ACCESS_TOKEN: ${{ secrets.SYNAPSE_ACCESS_TOKEN }}
134146
SERVICE_ACCOUNT_CREDS: ${{ secrets.SERVICE_ACCOUNT_CREDS }}
147+
OTEL_EXPORTER_OTLP_HEADERS: "Authorization=Bearer ${{ steps.retrieve-telemetry-access-token.outputs.TELEMETRY_ACCESS_TOKEN }}"
148+
DEPLOYMENT_ENVIRONMENT: ${{ vars.DEPLOYMENT_ENVIRONMENT }}
149+
OTEL_EXPORTER_OTLP_ENDPOINT: ${{ vars.OTEL_EXPORTER_OTLP_ENDPOINT }}
150+
TRACING_EXPORT_FORMAT: ${{ vars.TRACING_EXPORT_FORMAT }}
151+
LOGGING_EXPORT_FORMAT: ${{ vars.LOGGING_EXPORT_FORMAT }}
152+
TRACING_SERVICE_NAME: ${{ vars.TRACING_SERVICE_NAME }}
153+
LOGGING_SERVICE_NAME: ${{ vars.LOGGING_SERVICE_NAME }}
154+
SERVICE_INSTANCE_ID: ${{ github.head_ref || github.ref_name }}
135155
run: >
136156
poetry run pytest --durations=0 --cov-append --cov-report=term --cov-report=html:htmlcov --cov-report=xml:coverage.xml --cov=schematic/
137157
-m "not (rule_benchmark or single_process_execution)" --reruns 4 -n 8 --ignore=tests/unit
@@ -141,6 +161,13 @@ jobs:
141161
env:
142162
SYNAPSE_ACCESS_TOKEN: ${{ secrets.SYNAPSE_ACCESS_TOKEN }}
143163
SERVICE_ACCOUNT_CREDS: ${{ secrets.SERVICE_ACCOUNT_CREDS }}
164+
OTEL_EXPORTER_OTLP_HEADERS: "Authorization=Bearer ${{ steps.retrieve-telemetry-access-token.outputs.TELEMETRY_ACCESS_TOKEN }}"
165+
DEPLOYMENT_ENVIRONMENT: ${{ vars.DEPLOYMENT_ENVIRONMENT }}
166+
OTEL_EXPORTER_OTLP_ENDPOINT: ${{ vars.OTEL_EXPORTER_OTLP_ENDPOINT }}
167+
TRACING_EXPORT_FORMAT: ${{ vars.TRACING_EXPORT_FORMAT }}
168+
LOGGING_EXPORT_FORMAT: ${{ vars.LOGGING_EXPORT_FORMAT }}
169+
TRACING_SERVICE_NAME: ${{ vars.TRACING_SERVICE_NAME }}
170+
LOGGING_SERVICE_NAME: ${{ vars.LOGGING_SERVICE_NAME }}
144171
run: >
145172
poetry run pytest --durations=0 --cov-append --cov-report=term --cov-report=html:htmlcov --cov-report=xml:coverage.xml --cov=schematic/
146173
-m "single_process_execution" --reruns 4 --ignore=tests/unit

CONTRIBUTION.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in
66

77
## How to report bugs or feature requests
88

9-
You can **create bug and feature requests** through [Sage Bionetwork's FAIR Data service desk](https://sagebionetworks.jira.com/servicedesk/customer/portal/5/group/8). Providing enough details to the developers to verify and troubleshoot your issue is paramount:
9+
You can **create bug and feature requests** through [Sage Bionetwork's DPE schematic support](https://sagebionetworks.jira.com/servicedesk/customer/portal/5/group/7/create/225). Providing enough details to the developers to verify and troubleshoot your issue is paramount:
1010
- **Provide a clear and descriptive title as well as a concise summary** of the issue to identify the problem.
1111
- **Describe the exact steps which reproduce the problem** in as many details as possible.
1212
- **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
@@ -25,7 +25,7 @@ For new features, bugs, enhancements:
2525

2626
#### 1. Branch Setup
2727
* Pull the latest code from the develop branch in the upstream repository.
28-
* Checkout a new branch formatted like so: `develop-<feature/fix-name>` from the develop branch
28+
* Checkout a new branch formatted like so: `<JIRA-ID>-<feature/fix-name>` from the develop branch
2929

3030
#### 2. Development Workflow
3131
* Develop on your new branch.
@@ -35,22 +35,22 @@ For new features, bugs, enhancements:
3535
* You can choose to create a draft PR if you prefer to develop this way
3636

3737
#### 3. Branch Management
38-
* Push code to `develop-<feature/fix-name>` in upstream repo:
38+
* Push code to `<JIRA-ID>-<feature/fix-name>` in upstream repo:
3939
```
40-
git push <upstream> develop-<feature/fix-name>
40+
git push <upstream> <JIRA-ID>-<feature/fix-name>
4141
```
42-
* Branch off `develop-<feature/fix-name>` if you need to work on multiple features associated with the same code base
42+
* Branch off `<JIRA-ID>-<feature/fix-name>` if you need to work on multiple features associated with the same code base
4343
* After feature work is complete and before creating a PR to the develop branch in upstream
4444
a. ensure that code runs locally
4545
b. test for logical correctness locally
4646
c. run `pre-commit` to style code if the hook is not installed
4747
c. wait for git workflow to complete (e.g. tests are run) on github
4848

4949
#### 4. Pull Request and Review
50-
* Create a PR from `develop-<feature/fix-name>` into the develop branch of the upstream repo
50+
* Create a PR from `<JIRA-ID>-<feature/fix-name>` into the develop branch of the upstream repo
5151
* Request a code review on the PR
5252
* Once code is approved merge in the develop branch. The **"Squash and merge"** strategy should be used for a cleaner commit history on the `develop` branch. The description of the squash commit should include enough information to understand the context of the changes that were made.
53-
* Once the actions pass on the main branch, delete the `develop-<feature/fix-name>` branch
53+
* Once the actions pass on the main branch, delete the `<JIRA-ID>-<feature/fix-name>` branch
5454

5555
### Updating readthedocs documentation
5656
1. Navigate to the docs directory.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ RUN poetry install --no-interaction --no-ansi --no-root
2929

3030
COPY . ./
3131

32-
RUN poetry install --only-root
32+
RUN poetry install --only-root

env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ SERVICE_ACCOUNT_CREDS='Provide service account creds'
1111
# LOGGING_EXPORT_FORMAT=otlp
1212
# TRACING_SERVICE_NAME=schematic-api
1313
# LOGGING_SERVICE_NAME=schematic-api
14+
## Instance ID is used during integration tests export to identify the git branch
15+
# SERVICE_INSTANCE_ID=schematic-1234
1416
## Other examples: dev, staging, prod
1517
# DEPLOYMENT_ENVIRONMENT=local
1618
# OTEL_EXPORTER_OTLP_ENDPOINT=https://..../telemetry

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "schematicpy"
3-
version = "24.11.2"
3+
version = "24.12.1"
44
description = "Package for biomedical data model and metadata ingress management"
55
authors = [
66
"Milen Nikolov <milen.nikolov@sagebase.org>",

schematic/__init__.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
from opentelemetry.instrumentation.flask import FlaskInstrumentor
1111
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
1212
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
13-
from opentelemetry.sdk.resources import DEPLOYMENT_ENVIRONMENT, SERVICE_NAME, Resource
13+
from opentelemetry.sdk.resources import (
14+
DEPLOYMENT_ENVIRONMENT,
15+
SERVICE_INSTANCE_ID,
16+
SERVICE_NAME,
17+
SERVICE_VERSION,
18+
Resource,
19+
)
1420
from opentelemetry.sdk.trace import TracerProvider
1521
from opentelemetry.sdk.trace.export import BatchSpanProcessor, Span
1622
from opentelemetry.sdk.trace.sampling import ALWAYS_OFF
@@ -20,6 +26,7 @@
2026

2127
from schematic.configuration.configuration import CONFIG
2228
from schematic.loader import LOADER
29+
from schematic.version import __version__
2330
from schematic_api.api.security_controller import info_from_bearer_auth
2431

2532
Synapse.allow_client_caching(False)
@@ -91,16 +98,14 @@ def set_up_tracing(session: requests.Session) -> None:
9198
Synapse.enable_open_telemetry(True)
9299
tracing_service_name = os.environ.get("TRACING_SERVICE_NAME", "schematic-api")
93100
deployment_environment = os.environ.get("DEPLOYMENT_ENVIRONMENT", "")
101+
service_instance_id = os.environ.get("SERVICE_INSTANCE_ID", "")
94102
trace.set_tracer_provider(
95103
TracerProvider(
96104
resource=Resource(
97105
attributes={
106+
SERVICE_INSTANCE_ID: service_instance_id,
98107
SERVICE_NAME: tracing_service_name,
99-
# TODO: Revisit this portion later on. As of 11/12/2024 when
100-
# deploying this to ECS or running within a docker container,
101-
# the package version errors out with the following error:
102-
# importlib.metadata.PackageNotFoundError: No package metadata was found for schematicpy
103-
# SERVICE_VERSION: package_version,
108+
SERVICE_VERSION: __version__,
104109
DEPLOYMENT_ENVIRONMENT: deployment_environment,
105110
}
106111
)
@@ -122,11 +127,14 @@ def set_up_logging(session: requests.Session) -> None:
122127
logging_export = os.environ.get("LOGGING_EXPORT_FORMAT", None)
123128
logging_service_name = os.environ.get("LOGGING_SERVICE_NAME", "schematic-api")
124129
deployment_environment = os.environ.get("DEPLOYMENT_ENVIRONMENT", "")
130+
service_instance_id = os.environ.get("SERVICE_INSTANCE_ID", "")
125131
if logging_export == "otlp":
126132
resource = Resource.create(
127133
{
134+
SERVICE_INSTANCE_ID: service_instance_id,
128135
SERVICE_NAME: logging_service_name,
129136
DEPLOYMENT_ENVIRONMENT: deployment_environment,
137+
SERVICE_VERSION: __version__,
130138
}
131139
)
132140

0 commit comments

Comments
 (0)