-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Exabyte-io/chore/SOF-7185
chore/SOF-7185 - pre-build PY modules, update names to @mat3ra, mat3ra-
- Loading branch information
Showing
23 changed files
with
183 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,105 @@ | ||
# Standata | ||
|
||
Standard data for digital materials R&D entities in the [ESSE](https://github.com/Exabyte-io/esse) data format. | ||
|
||
Examples of entity data structures in the [ESSE](https://github.com/Exabyte-io/esse) data format (Essential Source | ||
of Schemas and Examples). | ||
|
||
## Installation | ||
## 1. Installation | ||
|
||
### Python | ||
|
||
The `standata` package is compatible with Python 3.8+. It can be installed as a Python package either via PyPI | ||
or as an editable local installation as below. | ||
### 1.1. Python | ||
|
||
The package is compatible with Python 3.8+. It can be installed as a Python package either via PyPI: | ||
```shell | ||
pip install standata | ||
pip install mat3ra-standata | ||
``` | ||
|
||
Editable local installation in a virtual environment: | ||
Or as an editable local installation in a virtual environment after cloning the repository: | ||
```shell | ||
virtualenv .venv | ||
source .venv/bin/activate | ||
pip install -e PATH_TO_STANDATA_REPOSITORY | ||
``` | ||
|
||
### Node | ||
### 1.2. JavaScript | ||
|
||
Standata can be installed as a Node.js package via NPM (node package manager). | ||
|
||
```shell | ||
npm install @exabyte-io/standata | ||
npm install @mat3ra/standata | ||
``` | ||
|
||
#### Runtime Data | ||
|
||
## 2. Usage | ||
|
||
### 2.1. Python | ||
|
||
```python | ||
from mat3ra.standata.materials import materials_data | ||
# This returns a list of JSON configs for all materials. | ||
materialConfigs = materials_data["filesMapByName"].values(); | ||
``` | ||
|
||
|
||
### 2.2. JavaScript | ||
|
||
```javascript | ||
// Direct import can be used to avoid importing all data at once. | ||
import data from "@mat3ra/standata/lib/runtime_data/materials"; | ||
// This creates a list of JSON configs for all materials. | ||
const materialConfigs = Object.values(data.filesMapByName); | ||
``` | ||
|
||
|
||
## 3. Conventions | ||
|
||
#### 3.1. Runtime Modules | ||
|
||
To avoid file system calls on the client, the entity categories and data structures are made available at runtime via | ||
the files in `src/js/runtime_data`. These files are generated automatically using the following command: | ||
```shell | ||
npm run build:runtime-data | ||
``` | ||
|
||
## CLI Script | ||
## 3.2. CLI Scripts for Creating Symlinks | ||
|
||
### 3.2.1. Python | ||
|
||
### Python | ||
The Python package adds a command line script `standata-symlinks` that creates a category-based file tree where | ||
The Python package adds a command line script `create-symlinks` that creates a category-based file tree where | ||
entity data files are symbolically linked in directories named after the categories associated with the entity. | ||
The resulting file tree will be contained in a directory names `by_category`. | ||
The script expects the (relative or absolute) path to an entity config file (`categories.yml`). The destination | ||
of the file tree can be modified by passing the `--destination`/`-d` option. | ||
```shell | ||
# consult help page to view all options | ||
standata-symlinks --help | ||
|
||
create-symlinks --help | ||
# creates symbolic links in materials/by_category | ||
standata-symlinks materials/categories.yml | ||
|
||
create-symlinks materials/categories.yml | ||
# creates symbolic links for materials in tmp/by_category | ||
standata-symlinks materials/categories.yml | ||
create-symlinks materials/categories.yml -d tmp | ||
``` | ||
|
||
### Node | ||
### 3.2.1 JavaScript/Node | ||
|
||
Analogous to the command line script in Python, the repository also features a script in | ||
TypeScript (`src/js/cli.ts`) and (after transpiling) in JavaScript (`lib/cli.js`). | ||
The script takes the entity config file as a mandatory positional argument and the | ||
alternative location for the directory containing the symbolic links (`--destination`/`-d`). | ||
```shell | ||
# creates symbolic links in materials/by_category (node) | ||
node lib/cli.js materials/categories.yml | ||
|
||
# creates symbolic links in materials/by_category (ts-node) | ||
ts-node src/js/cli.ts materials/categories.yml | ||
|
||
# creates symbolic links for materials in tmp/by_category | ||
ts-node src/js/cli.ts -d tmp materials/categories.yml | ||
|
||
# run via npm | ||
npm run build:categories -- materials/categories.yml | ||
|
||
``` | ||
|
||
|
||
## 4. Development | ||
|
||
See [ESSE](https://github.com/Exabyte-io/esse) for the notes about development and testing. | ||
|
||
|
||
## 5. Links | ||
|
||
To be added here. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.