Skip to content

Commit

Permalink
Fixing release (#73)
Browse files Browse the repository at this point in the history
* Fix pybis release

* Fix again...

* Fix export_to_excel CLI

Added functionality for DATAMODEL_DIR being dynamically obtained (either in bam_masterdata or in external folder

* Added instruction to README
  • Loading branch information
JosePizarro3 authored Feb 5, 2025
1 parent 50d9aba commit 4e0ec06
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@

The BAM Masterdata is a repository containing all the masterdata schema defining in BAM, as well as some utility functions to handle the masterdata.

<!--
## Getting started
If you want to install it, do:
```sh
pip install bam-masterdata
```

Add here installation instructions once the package is deployed -->
In order to include the CLI functionalities, you have to add the optional `[dev]` dependencies when pip installing the package:
```sh
pip install bam-masterdata[dev]
```

## Development

Expand Down
26 changes: 22 additions & 4 deletions bam_masterdata/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,26 @@
listdir_py_modules,
)

DATAMODEL_DIR = os.path.join(".", "bam_masterdata", "datamodel")

def find_datamodel_dir():
"""Search for 'datamodel/' in possible locations and return its absolute path."""
possible_locations = [
# Case: Running from a project with `datamodel/`
Path.cwd() / "datamodel",
# Case: Running inside bam-masterdata
Path.cwd() / "bam_masterdata" / "datamodel",
# Case: Running inside installed package
Path(__file__).parent / "datamodel",
]

for path in possible_locations:
if path.exists():
return str(path.resolve())

raise FileNotFoundError("Could not find a valid 'datamodel/' directory.")


DATAMODEL_DIR = find_datamodel_dir()


@click.group(help="Entry point to run `bam_masterdata` CLI commands.")
Expand Down Expand Up @@ -188,9 +207,8 @@ def export_to_excel(force_delete, python_path):
py_modules = listdir_py_modules(directory_path=python_path, logger=logger)

# Load the definitions module classes
definitions_module = import_module(
module_path="./bam_masterdata/metadata/definitions.py"
)
definitions_path = Path(__file__).parent / ".." / "metadata" / "definitions.py"
definitions_module = import_module(module_path=str(definitions_path.resolve()))

# Process the modules and save the entities to the openBIS masterdata Excel file
masterdata_file = os.path.join(".", "artifacts", "masterdata.xlsx")
Expand Down

2 comments on commit 4e0ec06

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage

Coverage Report
FileStmtsMissCoverMissing
bam_masterdata
   logger.py80100% 
bam_masterdata/cli
   cli.py794646 42%
   entities_to_excel.py5433 94%
   entities_to_json.py3655 86%
   fill_masterdata.py195181181 7%
bam_masterdata/datamodel
   collection_types.py370100% 
   dataset_types.py184184184 0%
   object_types.py15150100% 
   property_types.py8000100% 
   vocabulary_types.py137210100% 
bam_masterdata/excel
   excel_to_entities.py191167167 13%
bam_masterdata/metadata
   definitions.py780100% 
   entities.py5433 94%
bam_masterdata/openbis
   get_entities.py534343 19%
   login.py633 50%
bam_masterdata/utils
   utils.py622121 66%
TOTAL1707365696% 

Tests Skipped Failures Errors Time
72 1 💤 0 ❌ 0 🔥 18.774s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

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

Coverage

Coverage Report
FileStmtsMissCoverMissing
bam_masterdata
   logger.py80100% 
bam_masterdata/cli
   cli.py794646 42%
   entities_to_excel.py5433 94%
   entities_to_json.py3655 86%
   fill_masterdata.py195181181 7%
bam_masterdata/datamodel
   collection_types.py370100% 
   dataset_types.py184184184 0%
   object_types.py15150100% 
   property_types.py8000100% 
   vocabulary_types.py137210100% 
bam_masterdata/excel
   excel_to_entities.py191167167 13%
bam_masterdata/metadata
   definitions.py780100% 
   entities.py5433 94%
bam_masterdata/openbis
   get_entities.py534343 19%
   login.py633 50%
bam_masterdata/utils
   utils.py622121 66%
TOTAL1707365696% 

Tests Skipped Failures Errors Time
72 1 💤 0 ❌ 0 🔥 19.342s ⏱️

Please sign in to comment.