kopia lustrzana https://github.com/jupyterhub/repo2docker
Satisfy black
rodzic
fd6314d07d
commit
685c8a0544
|
@ -192,7 +192,9 @@ class RBuildPack(PythonBuildPack):
|
|||
# Ask for midnight UTC snapshot
|
||||
json={
|
||||
"repo": "all",
|
||||
"snapshot": (snapshot_date - datetime.timedelta(days=i)).strftime("%Y-%m-%dT00:00:00Z"),
|
||||
"snapshot": (snapshot_date - datetime.timedelta(days=i)).strftime(
|
||||
"%Y-%m-%dT00:00:00Z"
|
||||
),
|
||||
},
|
||||
).json()
|
||||
# Construct a snapshot URL that will give us binary packages for Ubuntu Bionic (18.04)
|
||||
|
@ -201,35 +203,36 @@ class RBuildPack(PythonBuildPack):
|
|||
"https://packagemanager.rstudio.com/all/__linux__/bionic/"
|
||||
+ snapshots["upsi"]
|
||||
)
|
||||
raise ValueError('No snapshot found for {} or {} days prior in packagemanager.rstudio.com'.format(
|
||||
snapshot_date.strftime("%Y-%m-%d"), max_days_prior
|
||||
))
|
||||
raise ValueError(
|
||||
"No snapshot found for {} or {} days prior in packagemanager.rstudio.com".format(
|
||||
snapshot_date.strftime("%Y-%m-%d"), max_days_prior
|
||||
)
|
||||
)
|
||||
|
||||
def get_mran_snapshot_url(self, snapshot_date, max_days_prior=7):
|
||||
for i in range(max_days_prior):
|
||||
try_date = snapshot_date - datetime.timedelta(days=i)
|
||||
# Fall back to MRAN if packagemanager.rstudio.com doesn't have it
|
||||
url = "https://mran.microsoft.com/snapshot/{}".format(
|
||||
try_date.isoformat()
|
||||
)
|
||||
url = "https://mran.microsoft.com/snapshot/{}".format(try_date.isoformat())
|
||||
r = requests.head(url)
|
||||
if r.ok:
|
||||
return url
|
||||
else:
|
||||
raise ValueError('No snapshot found for {} or {} days prior in mran.microsoft.com'.format(
|
||||
snapshot_date.strftime("%Y-%m-%d"), max_days_prior
|
||||
))
|
||||
raise ValueError(
|
||||
"No snapshot found for {} or {} days prior in mran.microsoft.com".format(
|
||||
snapshot_date.strftime("%Y-%m-%d"), max_days_prior
|
||||
)
|
||||
)
|
||||
|
||||
def get_cran_mirror_url(self, snapshot_date):
|
||||
# Date after which we will use rspm + binary packages instead of MRAN + source packages
|
||||
rspm_cutoff_date = datetime.date(2022, 1, 1)
|
||||
|
||||
if snapshot_date >= rspm_cutoff_date or self.r_version >= V('4.1'):
|
||||
if snapshot_date >= rspm_cutoff_date or self.r_version >= V("4.1"):
|
||||
return self.get_rspm_snapshot_url(snapshot_date)
|
||||
else:
|
||||
return self.get_mran_snapshot_url(snapshot_date)
|
||||
|
||||
|
||||
def get_devtools_snapshot_date(self):
|
||||
"""
|
||||
Return date of snapshot to use for getting devtools install
|
||||
|
|
|
@ -80,7 +80,8 @@ def test_snapshot_rspm_date():
|
|||
snapshot_url = r.get_rspm_snapshot_url(requested)
|
||||
print(snapshot_url)
|
||||
assert snapshot_url.startswith(
|
||||
"https://packagemanager.rstudio.com/all/__linux__/bionic/" + expected.strftime("%Y-%m-%d")
|
||||
"https://packagemanager.rstudio.com/all/__linux__/bionic/"
|
||||
+ expected.strftime("%Y-%m-%d")
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
|
|
Ładowanie…
Reference in New Issue