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

Generate vp reports #7

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Split PDF installation
alecandido committed Aug 12, 2022
commit ee300a8325f0636d15e2658af7506193bb6f3850
4 changes: 2 additions & 2 deletions src/mcpdf/cli/evolve.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

import click

from ..fit import evolve
from ..fit import evolve, install
from . import base

_logger = logging.getLogger(__name__)
@@ -55,7 +55,7 @@ def install_subcommand(pdf):

"""
try:
dest = evolve.install(pdf)
dest = install.install(pdf)
except FileExistsError:
_logger.error(f"'{pdf.name}' already installed")
return
20 changes: 0 additions & 20 deletions src/mcpdf/fit/evolve.py
Original file line number Diff line number Diff line change
@@ -4,12 +4,10 @@
import logging
import os
import pathlib
import shutil
import tempfile

import eko
import ekobox as eb
import lhapdf
import numpy as np
import numpy.typing as npt
from ekobox import genpdf
@@ -175,21 +173,3 @@ def update_prefix(pdf: os.PathLike):

for file in pdf.glob("*"):
file.rename(file.with_name(file.name.replace(prefix, pdf.name)))


def install(pdf: os.PathLike) -> pathlib.Path:
"""Install pdf in LHAPDF path.

Parameters
----------
pdf: os.PathLike
path to pdf directory

Returns
-------
str
destination path

"""
pdf = pathlib.Path(pdf).absolute()
return shutil.copytree(pdf, pathlib.Path(lhapdf.paths()[0]) / pdf.name)
37 changes: 37 additions & 0 deletions src/mcpdf/fit/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
"""Install PDF set."""
import os
import pathlib
import shutil

import lhapdf


def install(pdf: os.PathLike, force: bool = False) -> pathlib.Path:
"""Install PDF in LHAPDF path.

Parameters
----------
pdf: os.PathLike
path to pdf directory
force: bool
force reinstallation (thus does not fail if already existing)

Returns
-------
str
destination path

Raises
------
FileExistsError
if PDF set already present

"""
pdf = pathlib.Path(pdf).absolute()
dest = pathlib.Path(lhapdf.paths()[0]) / pdf.name

if force and dest.exists():
shutil.rmtree(dest)

return shutil.copytree(pdf, dest)