Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing release #73

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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