Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefanie08 committed Oct 11, 2024
2 parents c7b53bd + 4f93e74 commit cbd165c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
50 changes: 42 additions & 8 deletions oemof_b3/tools/testing_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def install_with_extra(extra):

def get_repo_path(current_path):
"""
This function sets the current path to the target directory.
This function sets the current path to oemof-B3 as target directory.
Inputs
-------
Expand Down Expand Up @@ -68,9 +68,8 @@ def get_repo_path(current_path):

def rename_path(file_path, before, after):
"""
This function checks if the file path is a directory or a file.
If the file path exists it renames the file or directory name
by appending the extension "_original".
This function renames an existing file in a directory or the directory itself (if passed with
file_path) by appending the extension "_original" to its name.
Inputs
-------
Expand All @@ -95,6 +94,7 @@ def rename_path(file_path, before, after):
# Add "_original" before the file extension
new_filename = filename.replace(before, after)
else:
# Todo: Make more robust by asking elif it is an directory
# Add extension "_original" to the directory name
new_filename = filename + "_original"

Expand All @@ -117,6 +117,18 @@ def rename_path(file_path, before, after):


def get_raw_path():
"""
This function returns the absolute path to raw directory
Inputs
-------
Outputs
-------
raw_dir_path : str
Absolute file path to directory raw
"""
this_path = os.path.abspath(os.getcwd())
repo_path = get_repo_path(this_path)
raw_dir_path = os.path.join(repo_path, "raw")
Expand All @@ -125,6 +137,18 @@ def get_raw_path():


def check_raw_data_exists():
"""
This function checks if raw data already exists in repo. If not the corresponding rule is
triggered. If the rule fails an exception is raised and user gets notified.
Inputs
-------
Outputs
-------
bool
True if raw data exists and False if it does not
"""
raw_dir_path = get_raw_path()

raw_dir_rule = ["raw/oemof-B3-raw-data.zip"]
Expand All @@ -147,6 +171,18 @@ def check_raw_data_exists():


def remove_raw_data_created(exists):
"""
This function
Inputs
-------
exists : bool
True if raw data exists and False if not
Outputs
-------
"""
raw_dir_path = get_raw_path()

if not exists:
Expand Down Expand Up @@ -180,8 +216,7 @@ def remove_test_data(path):

def get_abs_path_list(output_rule_list):
"""
This function finds the absolut file path for each rule
in the output_rule_list.
This function returns the absolut file path for each rule in the output_rule_list.
Inputs
-------
Expand All @@ -202,8 +237,7 @@ def get_abs_path_list(output_rule_list):

def file_name_extension(file_path):
"""
This function rearranges the current absolute file path
with the new extension '_original'.
This function rearranges the current absolute file path with the new extension '_original'.
Inputs
-------
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pipeline_raw_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This script checks the snakemake pipeline for the raw data download from Zenodo and
target rules that create empty time series and scalars in the folder raw.
This script checks the download of raw data in oemof-B3 and target rules of the snakemake pipeline
that create empty time series and scalars in the directory 'raw'.
"""
import os
import snakemake
Expand Down

0 comments on commit cbd165c

Please sign in to comment.