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

teamcity-solutions #562

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions FloodAdapt-GUI
Submodule FloodAdapt-GUI added at 54c0c6
30 changes: 25 additions & 5 deletions environment/make_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"stdout": subprocess.PIPE,
"stderr": subprocess.PIPE,
"universal_newlines": True,
"env": os.environ.copy(),
}

try:
Expand Down Expand Up @@ -64,6 +65,18 @@ def parse_args():
dest="optional_deps",
help="Install optional dependencies of FloodAdapt-GUI and FloodAdapt in addition the core ones. (linting, testing, etc.) Default is to not install any.",
)
parser.add_argument(
"--cicd",
required=False,
dest="is_cicd",
default=False,
action="store_true",
help="""Set this flag to skip the pip install commands, since they might require credentials.
Useful for CI/CD environments where the credentials are not available.
The environment will be created containing the geospatial packages, but the other pypi dependencies will not be installed.
To complete the environment, run the following command after activating it: pip install FloodAdapt
""",
)

args = parser.parse_args()
return args
Expand Down Expand Up @@ -100,6 +113,7 @@ def create_env(
env_name: str,
prefix: Optional[str] = None,
editable: bool = False,
is_cicd: bool = False,
optional_deps: Optional[str] = None,
):
if not BACKEND_ROOT.exists():
Expand All @@ -117,15 +131,19 @@ def create_env(
activate_option = env_location if prefix else env_name
activate_command = f"conda activate {activate_option}"

editable_option = "-e" if editable else ""
dependency_option = f"[{optional_deps}]" if optional_deps is not None else ""

command_list = [
"conda activate",
create_command,
activate_command,
f"pip install {editable_option} {BACKEND_ROOT.as_posix()}{dependency_option} --no-cache-dir",
]

if not is_cicd:
editable_option = "-e" if editable else ""
dependency_option = f"[{optional_deps}]" if optional_deps is not None else ""
command_list.append(activate_command)
command_list.append(
f"pip install {editable_option} {BACKEND_ROOT.as_posix()}{dependency_option} --no-cache-dir"
)

command = " && ".join(command_list)

print("Running commands:")
Expand All @@ -138,6 +156,7 @@ def create_env(
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
env=os.environ.copy(),
)

while process.poll() is None and process.stdout:
Expand Down Expand Up @@ -167,5 +186,6 @@ def create_env(
env_name=args.env_name,
prefix=args.prefix,
editable=args.editable,
is_cicd=args.is_cicd,
optional_deps=args.optional_deps,
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [
"fiat-toolbox",
"geojson",
"geopandas",
"hydromt-fiat@ git+https://github.com/deltares/hydromt_fiat.git@floodadapt",
"hydromt-fiat@ git+https://github.com/deltares/hydromt_fiat.git",
"hydromt-sfincs@ git+https://github.com/Deltares-research/hydromt_sfincs_insiders.git@FA_quadtree",
"numpy < 2.0",
"numpy-financial",
Expand Down
Loading