No project description provided
Project description
Quickstart
Step 1: Install the data package in your DISPATCHES environment using pip
conda activate dispatches-dev # or the name of your DISPATCHES dev environment
pip install git+https://github.com/gmlc-dispatches/synthetic-price-data
Step 2: Access the contents of the data package in your code using dispatches_data.api
Using dispatches_data.api.path()
:
from dispatches_data.api import path
# path_to_data_package is a standard pathlib.Path object
path_to_data_package = path("synthetic_price")
# subdirectories and files can be accessed using the pathlib.Path API
path_to_xml = path_to_data_package / "ARMA_train.xml"
assert path_to_xml.is_file()
# alternatively, if the file is located directly under the data package directory (i.e. not in a subdirectory):
# this will raise an exception if the file does not exist so we don't need to check explicitly
path_to_xml = path("synthetic_price", "ARMA_train.xml")
# if the path must be passed to a function that only accepts `str` objects, it can be converted using `str()`
path_to_xml_as_str = str(path_to_xml)
Using dispatches_data.api.files()
:
from dispatches_data.api import files
# `all_price_files` will be a list of pathlib.Path objects for each file matching the specified `pattern`
all_price_files = files("synthetic_price", pattern="Price_20*.csv")
# check that the list of found files is not empty
assert all_price_files
# `dispatches_data.api.files()` always returns a list, even if only one file matches
price_for_21 = files("synthetic_price", pattern="Price_*21.csv")[0]
Using the CLI interface:
NOTE this example uses UNIX shell syntax. It will not work on Windows unless adapted to the specific shell (e.g. Powershell) being used.
# calling `dispatches-data-packages` on the command line with the name of the data package
# will output the absolute path to the data package, which can then be saved as a shell variable
# and used to generate paths to files in the data package
path_to_data_package="$(dispatches-data-packages synthetic_price)"
path_to_xml_file="$path_to_data_package/ARMA_train.xml"
ls -lh "$path_to_data_package"
cp "$path_to_xml_file" .
# the entire contents of the data package can be copied to the current working directory
# if this is required by the client application
cp -r "$path_to_data_package"/* .
ls -lh .
Examples
Using the data package with the RAVEN CLI
NOTE this example uses UNIX shell syntax. It will not work on Windows unless adapted to the specific shell (e.g. Powershell) being used. TODO: must be tested
path_to_data_package="$(dispatches-data-packages synthetic_price)"
# copy contents to local directory
cp -r "$path_to_data_package"/* .
raven_framework ARMA_train.xml
Using the data package with shell commands in IPython/Jupyter notebooks
Both the IPython shell and Jupyter notebooks allow running arbitrary shell commands within a Python code shell by prefixing the command with !
.
Refer to the IPython documentation for details.
NOTE The command (minus the !
prefix) is passed verbatim to the system shell. Therefore, the exact syntax used in these examples may or may not work depending on the operating system (more specifically, on which shell is configured as the default).
Within a !
-prefixed line, the use of Python variables is supported by prefixing the variable name with $
or wrapping it between {}
.
The value of the Python variable will be converted to a string automatically before the command is passed to the shell.
Therefore, the following syntax can be used to use data packages within a IPython/Jupyter shell command:
from dispatches_data.api import path
xml_path = path("synthetic_price", "ARMA_train.xml)
# the $ syntax only supports simple variable names
!raven_framework $xml_path
# the {} syntax supports arbitrary Python expressions
!raven_framework {path("synthetic_price", "ARMA_train.xml")}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dispatches-synthetic-price-data-23.4.4.tar.gz
.
File metadata
- Download URL: dispatches-synthetic-price-data-23.4.4.tar.gz
- Upload date:
- Size: 291.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3cbef7888a27a60eb6d9d903376e6fb894b5138068d720c9bddbbb5cbf1e07d |
|
MD5 | 6180acc351a777c025b16ed6d6aa390d |
|
BLAKE2b-256 | 0905c477e2e255e59acef51b31dac0fc3a9df3929fc0638dc0b5135c1af3630a |
File details
Details for the file dispatches_synthetic_price_data-23.4.4-py3-none-any.whl
.
File metadata
- Download URL: dispatches_synthetic_price_data-23.4.4-py3-none-any.whl
- Upload date:
- Size: 290.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39cf663e7ebd9221111afca0dac4c5f7e50486010110e491560a3bd64e4c9ad7 |
|
MD5 | 64e8df571328a4961a438d822ec70bf9 |
|
BLAKE2b-256 | 526be56e6e841ff8c5abc00f4b3477ef65f9d8ad25cf574202351e2b7ba3dcd9 |