Skip to content
Draft
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
3 changes: 2 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
name: upload release to PyPI
runs-on: ubuntu-latest
environment: publish-release
if: ${{ github.repository == 'MazinLab/MKIDCore' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && !contains(github.event.ref, 'dev') }}

permissions:
# This permission is needed for private repositories.
contents: read
Expand All @@ -53,7 +55,6 @@ jobs:
- uses: actions/checkout@v3
- uses: pdm-project/setup-pdm@v3
- name: Publish package distributions to PyPI
if: ${{ github.repository == 'MazinLab/MKIDCore' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && !contains(github.event.ref, 'dev') }}
run: pdm publish

# smoketest: # If we plug this into downstream projects, does magic smoke escape?
Expand Down
6 changes: 1 addition & 5 deletions mkidcore/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import print_function
import re
import ruamel.yaml
from pkg_resources import Requirement, resource_filename
from mkidcore.utils import caller_name
from mkidcore.corelog import getLogger
from multiprocessing import RLock
Expand All @@ -16,6 +15,7 @@
import configparser
from io import StringIO


RESERVED = ('._c', '._a') #Internal keys hidden from the user for storing comments and

yaml = ruamel.yaml.YAML()
Expand All @@ -32,10 +32,6 @@ def __missing__(self, key):
DEFAULT_BMAP_CFGFILES = _BeamDict()


def defaultconfigfile():
return resource_filename(Requirement.parse("mkidcore"), "default.yml")


def extract_from_node(loader, keys, node):
"""attempt extraction of keys from a ruamel.yaml mapping node and return as a dict,
does not support tagged types"""
Expand Down
4 changes: 2 additions & 2 deletions mkidcore/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
from glob import glob
import json
import pkg_resources as pkg
from importlib import resources as rs
import csv
from bisect import bisect
from collections import defaultdict
Expand Down Expand Up @@ -147,7 +147,7 @@ def _parse_inst_keys(csv_file):
""" spaces to _ ? to null strip whitespace, keys are column 0 values are dict of other columns
all keys forced to lower case
"""
with open(pkg.resource_filename('mkidcore', csv_file)) as f:
with open(rs.files('mkidcore').joinpath(csv_file)) as f:
data = [row for row in csv.reader(f)]
data = [{k.strip().lower().replace(' ', '_').replace('?', ''): v.strip() for k, v in zip(data[0], l)} for l in
data[1:]]
Expand Down
9 changes: 4 additions & 5 deletions mkidcore/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
from mkidcore.instruments import DEFAULT_ARRAY_SIZES
from glob import glob
import pkg_resources as pkg
from importlib import resources as rs
import mkidcore.config
from mkidcore.corelog import getLogger
import copy
Expand All @@ -11,7 +11,6 @@
from datetime import datetime
import json


class TimeStream(object):
"""
Class for holding a resonator's phase time-stream.
Expand Down Expand Up @@ -151,10 +150,10 @@ def __init__(self, specifier='MEC', xydim=None, freqpath=''):
raise Exception('The dimensions of the beammap entered do not match the beammap read in')
else:
try:
self._load(pkg.resource_filename(__name__, '{}.bmap'.format(default.lower())))
self._load(rs.files(__name__).joinpath('{}.bmap'.format(default.lower())))
self.ncols, self.nrows = DEFAULT_ARRAY_SIZES[default.lower()]
except IOError:
opt = ', '.join([f.rstrip('.bmap').upper() for f in glob(pkg.resource_filename(__name__, '*.bmap'))])
opt = ', '.join([f.rstrip('.bmap').upper() for f in glob(rs.files(__name__).joinpath('*.bmap'))])
raise ValueError('Unknown default beampmap "{}". Options: {}'.format(default, opt))

@classmethod
Expand Down Expand Up @@ -481,4 +480,4 @@ def __str__(self):
return 'File: "{}"\n Well Mapped: {}'.format(self.file, self.nrows * self.ncols - (self.flags!=0).sum())


mkidcore.config.yaml.register_class(Beammap)
mkidcore.config.yaml.register_class(Beammap)
2 changes: 1 addition & 1 deletion tests/test_config_dict.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from unittest import TestCase
import ruamel.yaml
from mkidcore.config import ConfigThing, RESERVED, defaultconfigfile
from mkidcore.config import ConfigThing, RESERVED

yaml = ruamel.yaml.YAML()

Expand Down