Skip to main content

eases the saving and reading of files within a structured folder tree

Project description

Tests

FiLoc File Locator

Filoc makes the saving, reading and analysis of files easy: You files are the database.

Machine Learning Swiss Knife

In machine learning, we use it to schedule, record, and analyze hundreds of machine learning experiences without the need of any service.

Schedule Simulations

Prepare hyperparameters for all your simulations at one place in a pandas dataframe or in an excel sheet. Save the simulation configurations into the folder structure of your choice, along with the processing state.

Record Simulations

In the algorithm script, you do not need to introduce any dependency to filoc. Just open the files previously written in the simulation folder. Nevertheless, you can also use filoc to harmonize your file handling.

Analyze Simulations

While the simulation are running or after, you can get insight on any information about the current results. Filoc doesn't do any difference between the simulation state, the hyperparameters and the result files of your simulations: it handles all in the same way and displays statistical analysis along with the hyperparameters.

Basic

import os
from filoc import Filoc

loc = Filoc('/data/simid={simid:d}/epid={epid:d}/settings.json') 

#--------------------------------------------------------------
# Build the path for simid=0 and epid=1, then write to the file
#--------------------------------------------------------------
path1 = loc.get_path(simid=0, epid=1)  # /data/simid=0/epid=1/settings.json
os.makedirs(os.path.dirname(path1))
with open(path1, 'w') as f:
    f.write('Coucou')

#--------------------------------------------------------------
# Same for simid=0 and epid=1 with a more compact syntax
#--------------------------------------------------------------
with loc.open(dict(simid=0, epid=2), 'w') as f:  # file handle to /data/simid=0/epid=2/settings.json
    f.write('Salut')

#--------------------------------------------------------------
# Find all files on file system having simid=0
#--------------------------------------------------------------
paths = loc.find_paths(simid=0)          # ['/data/simid=0/epid=1/settings.json', '/data/simid=0/epid=2/settings.json']

#--------------------------------------------------------------
# Extract properties for path paths[0]
#--------------------------------------------------------------
props = loc.get_path_properties(paths[0]) # { 'simid': 0, 'epid': 1 }

#--------------------------------------------------------------
# More compact form to get both the paths and their related properties
#--------------------------------------------------------------
for path, props in loc.find_paths_and_properties(simid=0):
    print(path, props)

#--------------------------------------------------------------
# Analyse all files and build a report
#--------------------------------------------------------------
def get_file_report(f):
    content = f.read()
    return { 'content_length' : len(content) }

report = loc.report(dict(simid=0), get_file_report, 'r')

print(report) #-> [{"simid":0, "epid":1, "content_length":6}, {"simid":0, "epid":2, "content_length":5}]

from pandas import DataFrame
print(DataFrame(report)) #-> convert report to pandas DataFrame 

#--------------------------------------------------------------
# Analyse all files and build a report
#--------------------------------------------------------------
def my_analysis(f):
    content = f.read()
    return { 'content_length' : len(content) }

fimap = Filoc(loc, my_analysis)

report = fimap.read_contents(simid=0)

print(report) #-> [{"simid":0, "epid":1, "content_length":6}, {"simid":0, "epid":2, "content_length":5}]

from pandas import DataFrame
print(DataFrame(report)) #-> convert report to pandas DataFrame 

Install

pip install filoc

Syntax

The FiLoc constructor accepts a file path/url, which will finally be interpreted by fsspec. That way, it is possible to access ftp, HDFS or any other file repository supported by fsspec. The path is at the same time a format string with named placeholder, which will be parsed by the parse library. Each placeholder defines a property associated to the files to save, retrieve or analyse.

ToDos

  • Readme Doc
  • API Doc
  • File locking
  • Unit Test
    • Multiloc with different aggregation layers (snowflake)
    • File locking
  • Dev: Logging of edited files
  • Dev: File watcher
  • Dev: Excel File watcher / binder

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

filoc-0.0.8.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

filoc-0.0.8-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file filoc-0.0.8.tar.gz.

File metadata

  • Download URL: filoc-0.0.8.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for filoc-0.0.8.tar.gz
Algorithm Hash digest
SHA256 b4a73c559a99bd95003719a2a0eaf9c0e92232f57d3310c7aa7e3cf9f8b84488
MD5 d4cdcf20f6d02177e923b1ecaa73849f
BLAKE2b-256 c1802f054899d5fee76e3caf0726297b5f525738370f3948004b5eed24face6d

See more details on using hashes here.

File details

Details for the file filoc-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: filoc-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for filoc-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b5332ec56606718697309cf8051a2699e09fce3ae6f3f44caa932ed28fbd8afa
MD5 4bfbf717a2b168597dbe200ff41f236b
BLAKE2b-256 4b06fdcdb189f862e1408b33d6a99209987fd6e547a2d5626a58e83873d4624d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page