Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 1 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.9%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Small samples of using Spine tools
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 3
Topics
Metadata Files
Readme.md
Overview
This repository consists of 4 Spine-Toolbox projects.
1. Spine Demo
A project containing several Spine database to illustrate SpineOpt.jl functionalities (demo SpineOpt models) and SpineInterface.jl utilities (incl. improvising Julia JuMP models using SpineInterface to interact with SpineDB)
2. SpinePython
A demo project of a workflow to run a Python Tool and exchange data with other tools: Data Connection, Julia Tool, and Importer for JSON and CSV files.
The project workflow contains:
A dummy input CSV file in the "Input_files"
Data Connection;A Julia script wrapped in the "Julia"
Toolthat reads the given input CSV and writes to an output CSV file; the output CSV file is passed over to the "ImportCSV"Importerand other tools (see 3);A Python script wrapped in the "Python"
Toolthat reads the given input CSV and the output csv from the Julia script and writes to a JSON file and another CSV file; the JSON output file is passed to the "ImportJSON"Importer.
3. BuildTimeseries project
A demo workflow to attach "DateTime" index to TimeSeries data
4. Hydro reservoir example
A sample SpineOpt.jl model for hydro reservoir generation
Set up working environment for Spine toolkits
Set up working/development environment for SpineOpt and Spine Toolbox
- prerequisites:
Warning!!!: Under this configuration, only running the spinetoolbox requires activating the conda environment. Once the PyCall.jl is configured to use the conda python, don't activate the conda environment for julia related tasks, e.g. updating environment packages (doing this with the conda activated causes unnecessary error).
Note When the Python version has a major change (e.g. 3.1x to 3.1y), its conda environment might need recreating after deleting the old environment:
```console
conda remove -n env_name --all
```
Step 1 option 1. Build worry-free spinetoolbox in conda environment with Git:
In OS terminal (cmd or PowerShell):
```console
create the env with the latest available python,
replace the
pythonbypython=3.1xfor a specific versionmore packages, e.g.
pip, can be explicitly added before/after thepythonconda create -n spine-tools python
conda init # if the activation has no response conda activate spine-tools ```Install the active dev version
spinetoolbox(needGitinstalled):console python -m pip install git+https://github.com/spine-tools/spinetoolbox-devUpdate package to the latest commit: reinstall the package using the same command.
Install the official release version
spinetoolbox(noGitneeded):console python -m pip install spinetoolbox==0.x.yNote: if the versionx.y.zis not specified, the latest release version will be installed.
Step 1 option 2. Conda environment for spine development
Create a new conda virtual environment:
```console
create the env with the latest available python,
replace the
pythonbypython=3.1xfor a specific versionmore packages, e.g.
pip, can be explicitly added before/after thepythonconda create -n spine-dev python ```
install local spine packages in the development environment
spine-dev:```console (Win PowerShell/cmd) conda init # if the activation has no response conda activate spine-dev
option 1
$parentDir = ".\path\to\local\packages\" $packageNames = @( "Spine-Database-API", "spine-engine", "spine-items", "Spine-Toolbox" ) foreach ($pkg in $packageNames) { $fullPath = Join-Path -Path $parentDir -ChildPath $pkg python -m pip install -e "$fullPath" }
option 2
python -m pip install -e .\path\to\local\Spine-Database-API python -m pip install -e .\path\to\local\spine-engine python -m pip install -e .\path\to\local\spine-items python -m pip install -e .\path\to\local\Spine-Toolbox ``` Update packages to the latest commits:
- Pull from the GitHub repositories
- Rerun the above commands
Step 2. Assign the configured conda Python to PyCall in the Julia environment where SpineOpt.jl and SpineInterface.jl are installed
Both options above (the spine-dev and spine-tools conda env) require this step unless you install SpineOpt.jl and SpineInterface.jl through the default channel of Spine toolbox.
In OS terminal (cmd or PowerShell)
console conda activate spine-dev cd path\to\the\working\julia\enviromentIn Julia console
```julia
activate the working environment
cd("path\to\the\working\julia\enviroment") using Pkg; Pkg.activate(".")
Before building PyCall, set which python to use
1. the python of activated environment, also works with non-conda python
ENV["PYTHON"] = Sys.which("python")
2. or when a conda environment is activated
ENV["PYTHON"] = ENV["CONDA_PREFIX"] * "\python.exe"
3. or let PyCall to install its dedicated conda
ENV["PYTHON"] = ""
using Pkg; Pkg.build("PyCall") ```
Relaunch Julia and check which
Pythonis being used byPyCall:PyCall.pyprogramnameorPyCall.python(Optional) To enable
Juliacells in Jupyter notebooks:julia using Pkg; Pkg.update(); Pkg.build("IJulia")
(Deprecated) env configuration
Python (virtual) environment setup
- Download and install python interpreter
- Create a virtual environment: "
X:\path\to\python\interpretor -m venv Y:\path\to\virtual_env_folder" - In the Terminal, switch to the corresponding virtual environment
- Run "
deactivate" to exit current virenv - Run "
cd path\to\the\virenv\folder" - Run "
.\Scripts\activate" to activate the target virenv - Run "
pip install -e package" in terminal under the activated virtual environment (the "-e" option is only needed for installing editable package, see pip install options) When the ipython and ipykernel (maybe only ipykernel needed) packages are installed, command "pip install -e local\package" can be used in the Python console where the new virtual environment is launched.
- Run "
Julia environment setup
Install julia manually by the installer from julialang.org
Modify the environment variable "julia" to the latest Julia installed
- System environment variable (if you install Julia for all users):
"Control Panel\All Control Panel Items\System --> Advanced system settings --> Advanced --> Environmental Variables --> Edit in
Path"- under "User variables for
administrator_username" (only for the administrator, under "System variables" for all users)
- under "User variables for
- User environment variable (if you install Julia for the current user):
Search
environment variablesin the Windows taskbar --> "Edit environment variable for your account" --> Edit inPathunder "User variables forthe_current_username" - Edit in
Path: add or replace the existing directory byX:\path\to\Julia\Julia-x.ab\bin - In case the Jupyter notebook kernel needs updating (in a specific
env), do:julia Pkg.update(); Pkg.build("IJulia") - Renew the path of julia executable in VSCode
- Settings --> Search "julia" --> Julia: Environment Path / Julia: Executable Path
- System environment variable (if you install Julia for all users):
"Control Panel\All Control Panel Items\System --> Advanced system settings --> Advanced --> Environmental Variables --> Edit in
Build
PyCallenvironment: recommend theStep 2in the previous sectionThere are 3 ways by which
PyCall.jlcould work for theSpineInterface.jlcall usespinedb-api.pkg> add PyCall- Option 1 Install
spinedb_apito a built-in conda python created byPyCall.- Confirm the default conda python is linked:
julia julia> ENV["PYTHON"]="" julia> using PyCall, Pkg julia> Pkg.build("PyCall") - Find the conda python
- "X:\path\to\the\conda\python\folder\Scripts\pip.exe install -e path/to/local/spinedb_api"
- Confirm the default conda python is linked:
- Option 2 Install
spinedb_apito the parent python interpreter on which the virtual env is built (ref. PyCall documentation and PyCall issue with virtual environment)- Run (with ipython and ipykernel installed)
pip install -e path/to/local/spinedb_api - Otherwise,
X:\path\to\python\folder\Scripts\pip.exe install -e path/to/local/spinedb_api
- Run (with ipython and ipykernel installed)
- Build customised python interpreter:
- In Julia after activating the desired working environment:
julia julia> ENV["PYTHON"] = raw"C:\path\to\the\parent\python.exe" julia> import Pkg; Pkg.build("PyCall") - Option 3 For a dedicated virtual environment created by
venvandvirtualenv, PyCall could work provided that the Python executable used in the virtual environment is linked against the same libpython used by PyCall (condaenvironment not supported). See the explanation here.- In command line:
virtual_env_folder\Scripts\Activate.ps1 - In Julia after activating the desired working environment:
julia julia> ENV["PYTHON"] = Sys.which("python") julia> ENV["PYCALL_JL_RUNTIME_PYTHON"] = Sys.which("python") julia> import Pkg; Pkg.build("PyCall")
- In command line:
- Relaunch Julia and check which python the PyCall is using: `PyCall.pyprogramname` or `PyCall.python`
- Check packages that are available for the PyCall used python:
```julia
julia> using PyCall; pyimport("sys").path
py"""
import pkgutil
def get_available_packages():
available_packages = [name for _, name, _ in pkgutil.iter_modules()]
return available_packages
"""
available_packages = py"get_available_packages"()
println(available_packages)
```
When `spinedb_api` package is in the list, it is good to go.
- Install Spine related jl package:
- pkg> dev "...path to SpineOpt folder...", pkg> dev "...path to SpineInterface folder..."
Owner
- Name: Huang-Jiangyi
- Login: nnhjy
- Kind: user
- Location: Zurich, Switzerland
- Company: ETH Zurich
- Repositories: 14
- Profile: https://github.com/nnhjy
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Huang" given-names: "Jiangyi" orcid: "https://orcid.org/0000-0002-0093-2276" title: "Spine-Samples" version: v0.0.1 date-released: 2023-05-18 url: "https://github.com/nnhjy/Spine-Samples"
GitHub Events
Total
- Push event: 5
Last Year
- Push event: 5
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| nnhjy | j****g@o****m | 76 |
| Huang, Jiangyi | j****g@v****i | 4 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 9 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0